dev-master
9999999-devWires callback functions to Supervisor events
MIT
The Requires
- php >=5.3.2
event supervisor supervisord
v1.0.0
1.0.0.0Wires callback functions to Supervisor events
MIT
The Requires
- php >=5.3.2
event supervisor supervisord
Wallogit.com
2017 © Pedro Peláez
Wires callback functions to Supervisor events
Receives event notifications from Supervisor and sends the parsed notification to a callback function., (*1)
The recommended installation method is through Composer., (*2)
Add mtdowling/supervisor-event as a dependency in your project's composer.json file:, (*3)
{
"require": {
"mtdowling/supervisor-event": "*"
}
}
Download and install Composer:, (*4)
curl -s http://getcomposer.org/installer | php
Install your dependencies:, (*5)
php composer.phar install
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)
<?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;
});
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
Wires callback functions to Supervisor events
MIT
event supervisor supervisord
Wires callback functions to Supervisor events
MIT
event supervisor supervisord