tectiv3 / libdaemon
dev-master
2016-08-22 00:30 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-07 15:43:40 UTC
README
创建并运行带有自定义工作进程的php守护进程
安装
安装
composer require tectiv3/libdaemon
定义工作进程并运行守护进程
定义工作进程
use Daemon\Worker;
class ExampleWorker extends Worker {
function run_cycle() {
echo "I'm a work horse!\n";
}
}
创建配置文件
[default]
logfile = "daemon.log"
pidfile = "daemon.pid"
daemonize = true
worker_class = "ExampleWorker"
max_children = 2
运行守护进程
$master = new Master('config.ini', 3600); //restart workers every hour
$master->start();
示例
示例可以在examples/
文件夹中找到