定制 mtdowling/supervisor-event 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mtdowling/supervisor-event

最新稳定版本:v1.0.0

Composer 安装命令:

composer require mtdowling/supervisor-event

包简介

Wires callback functions to Supervisor events

README 文档

README

Receives event notifications from Supervisor and sends the parsed notification to a callback function.

Requirements

  • PHP 5.3
  • Supervisord

Installation

The recommended installation method is through Composer.

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

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

     curl -s http://getcomposer.org/installer | php 
  3. Install your dependencies:

     php composer.phar install 
  4. Require Composer's autoloader

    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:

     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.

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:

[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

Now run:

supervisorctl reload 

统计信息

  • 总下载量: 171.93k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 124
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 123
  • Watchers: 9
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04