2017 © Pedro Peláez
 

component supervisor-event

Wires callback functions to Supervisor events

image

mtdowling/supervisor-event

Wires callback functions to Supervisor events

  • Monday, July 23, 2012
  • by mtdowling
  • Repository
  • 7 Watchers
  • 98 Stars
  • 15,487 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 15 Forks
  • 2 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

PHP Supervisor Event Framework

Receives event notifications from Supervisor and sends the parsed notification to a callback function., (*1)

Requirements

  • PHP 5.3
  • Supervisord

Installation

The recommended installation method is through Composer., (*2)

  1. Add mtdowling/supervisor-event as a dependency in your project's composer.json file:, (*3)

    {
        "require": {
            "mtdowling/supervisor-event": "*"
        }
    }
  2. Download and install Composer:, (*4)

    curl -s http://getcomposer.org/installer | php
  3. Install your dependencies:, (*5)

    php composer.phar install
  4. Require Composer's autoloader, (*6)

    Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process:, (*7)

    require 'vendor/autoload.php';

You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org., (*8)

Example event script

<?php

// include the composer autoloader
require_once __DIR__ . '/vendor/autoload.php';

use Mtdowling\Supervisor\EventListener;
use Mtdowling\Supervisor\EventNotification;

$listener = new EventListener();
$listener->listen(function(EventListener $listener, EventNotification $event) {
    $listener->log($event->getEventName());
    $listener->log($event->getServer());
    $listener->log($event->getPool());
    // Try messing around with supervisorctl to restart processes and see what
    // data is available
    $listener->log(var_export($event->getData(), true));
    return true;
});

Running the example

Open your supervisord.conf file and add the following:, (*9)

[eventlistener:event_listener]
command=php /path/to/examples/log.php
process_name=%(program_name)s_%(process_num)02d
numprocs=1
events=PROCESS_STATE_STARTING,TICK_5
autostart=true
autorestart=unexpected

Replace /path/to with the correct path. More event listener options can be found at http://supervisord.org/events.html, (*10)

Now run:, (*11)

supervisorctl reload

The Versions

23/07 2012

dev-master

9999999-dev

Wires callback functions to Supervisor events

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

event supervisor supervisord

23/07 2012

v1.0.0

1.0.0.0

Wires callback functions to Supervisor events

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

event supervisor supervisord