2017 © Pedro Peláez
 

library daemonhelper

Helper classes for daemon processes written in PHP

image

nexxes/daemonhelper

Helper classes for daemon processes written in PHP

  • Monday, February 5, 2018
  • by dennisbirkholz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php-daemonhelper

Helper classes for daemon processes written in PHP, licenced under the LGPL v3., (*1)

Installation

Just put the following in your composer.json file inside your project root. No stable version exists so far., (*2)

"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();

The Versions

05/02 2018

dev-master

9999999-dev

Helper classes for daemon processes written in PHP

  Sources   Download

LGPL3 LGPL-3.0-only

The Development Requires

by Dennis Birkholz