alanpich/daemon

Lightweight wrapper for starting & stopping background processes

dev-master 2013-11-26 13:41 UTC

This package is not auto-updated.

Last update: 2024-04-22 23:25:49 UTC


README

====================

Spawns background processes via PHP. Can also stop them again

Installation

{
    "require": {
        "alanpich/php-daemon": "*"
    }
}

Usage

// Command to execute
$script = 'php '.dirname(__FILE__).'/index.php';
// File to log to
$logFile = dirname(__FILE__).'/log.txt';
// Path to save pid file to
$pidFile = dirname(__FILE__).'/process.pid';
// Create the daemon wrapper
$daemon = new \AlanPich\Daemon\DaemonProcess($script,$pidFile,$logFile);


$daemon->start();

echo $daemon->status()? 'RUNNING' : 'NOT RUNNING';

$daemon->stop();