定制 neutron/signal-handler 二次开发

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

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

neutron/signal-handler

最新稳定版本:1.0.1

Composer 安装命令:

composer require neutron/signal-handler

包简介

A library to ease the use of signal handling.

关键字:

README 文档

README

Build Status

A simple signal handler to manage incoming posix signals.

It is implemented as a singleton as pcntl_signal can only register one callback per signal.

Using this one, you can register as many callbacks per signal as needed.

For more information about signals, man signal.

// mandatory to listen to signals
declare(ticks=1);
$handler = Neutron\SignalHandler\SignalHandler::getInstance();
$handler->register(array(SIGINT, SIGTERM), function () { echo "stoppin !"; exit(); });
$handler->register(SIGCONT, function () { echo "all systems go..."; });

Register a signal handler

// register a handler for SIGCONT in default namespace
$handler->register(SIGCONT, function () { echo "SIGCONT received"; });
// register a handler for SIGCONT in "a namespace"
$handler->register(SIGCONT, function () { echo "SIGCONT received"; }, 'a namespace');
// register a handler for SIGCONT in "another namespace"
$handler->register(SIGINT, function () { echo "Interrupted !"; exit(); }, 'another namespace');

Unregister signals handler

Two ways are available to unregister signals.

By namespace :

// unregister all handlers in "another namespace"
$handler->unregisterNamespace('another namespace');
// unregister all SIGINT handlers in "a namespace"
$handler->unregisterNamespace('a namespace', SIGINT);

By signal :

// unregister all SIGINT handlers in any namespace
$handler->unregisterSignal(SIGINT);

License

This project is released under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-11