2017 © Pedro Peláez
 

library php-cron-daemon

PHP daemon for script and cronjob

image

wiryonolau/php-cron-daemon

PHP daemon for script and cronjob

  • Wednesday, April 11, 2018
  • by wiryono
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-cron-daemon

This a library to enable daemon task with php application using zf2 and pcntl extension., (*1)

Install using, (*2)

composer require wiryonolau/php-cron-daemon

Add to your module.config.php, below is example, (*3)

"cron_daemon" => array(
    array(
        "program" => "/usr/bin/php"
        "arguments" => array("/public/index.php", "application", "init", "-y"),
        "schedule" => "* * * * *",
        "work_count" => 1,
        "timeout" => 10
    )
)

Parameters - program : an executable - arguments : script path and their argument separate with array - schedule (optional) : - default to false, it will be run as many as work_count once, useful for infinite loop script such as rabbitmq worker - if specify ( must use cronjob format ) , daemon will run it when schedule is reach - work_count ( optional ) : default to 1 maximum 10, how many script have to run for current task - timeout (optional) : task timeout in second default is 0 no timeout, (*4)

To run the script as daemon you can use either init.d or systemd, (*5)

If you use php task that using phpampqlib set set_close_on_destruct to false, so daemon can kill it gracefully without leaving zombie process, (*6)

$connection->set_close_on_destruct(false);

The Versions

04/12 2017

dev-master

9999999-dev https://github.com/wiryonolau/php-cron-daemon

PHP daemon for script and cronjob

  Sources   Download

MIT License

The Requires

 

by Wiryono Lau

zf2 zend framework 2