nexxes/daemonhelper
Composer 安装命令:
composer require nexxes/daemonhelper
包简介
Helper classes for daemon processes written in PHP
README 文档
README
Helper classes for daemon processes written in PHP, licenced under the LGPL v3.
Installation
Just put the following in your composer.json file inside your project root.
No stable version exists so far.
"require": { "nexxes/daemonhelper": "*@dev" }
Features
Daemonize a process
// Daemonize the current process: // - process will be detached from terminal and becomes process group leader // - stdin/stderr will be closed and reopened to the supplied files (default is /dev/null) // - daemon will re-exec itself so STDIN, STDOUT, STDERR constants are fixed \nexxes\Daemon::daemonize('run/process.pid', 'log/stderr.log', 'log/stdout.log', 'stdin.txt'); // Code after daemonizing follows here // ...
WatchDog to restart a worker process on error
// Fork the real worker process \nexxes\WatchDog::run(); // Code for the worker process // If the process dies with exit-value != 0, // we start here again and again and again // ..
WatchDog for multiple worker processes
// Multiple processes can be handled by a watchdog instance $watchdog = new \nexxes\WatchDog(); $watchdog->addProcess('processName1', function() { // Code for process 1 // If the process dies with exit-value != 0, // we start here again ... }); $watchdog->addProcess('processNameX', function() { // Register as many processes as you need. // You can register anything callable, not only closures. }); // Execute the processes and restart them if needed: $watchdog->start();
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2015-07-06