Wallogit.com
2017 © Pedro Peláez
Create and run php daemon with custom workers, (*1)
Installation, (*2)
composer require tectiv3/libdaemon, (*3)
Define workers, (*4)
use Daemon\Worker;
class ExampleWorker extends Worker {
function run_cycle() {
echo "I'm a work horse!\n";
}
}
Create config, (*5)
[default]
logfile = "daemon.log"
pidfile = "daemon.pid"
daemonize = true
worker_class = "ExampleWorker"
max_children = 2
Run daemon, (*6)
$master = new Master('config.ini', 3600); //restart workers every hour
$master->start();
Examples can be found in the examples/ folder, (*7)