alanpich/daemon

启动和停止后台进程的轻量级包装器

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

This package is not auto-updated.

Last update: 2024-09-24 01:20:50 UTC


README

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

通过PHP启动后台进程。也可以再次停止它们

安装

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

使用方法

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