aboutcoders/process-control

1.3.2 2016-12-30 15:26 UTC

This package is not auto-updated.

Last update: 2024-09-26 00:14:48 UTC


README

PHP进程控制库。

构建状态: 构建状态

接口

ControllerInterface 定义了 doExit() 方法,该方法指示是否退出进程。

interface ControllerInterface
{
    /**
     * Indicates whether to exit a process
     *
     * @return boolean
     */
    public function doExit();
}

PcntlController

PcntlController 监听 PCNTL 事件以确定是否退出进程。

    $stopsignals = array(SIGTERM);
    $logger = new Psr\Log\NullLogger();
    
    $controller = new PcntlController($stopsignals, $logger);
    
    while(!$controller->doExit())
    {
        // do something
    }

ChainController

ChainController 通过链式执行多个控制器来决定是否退出进程。

NullController

NullController 从不指示退出进程。

注意:此控制器可以用作在PCNTL函数不存在的运行环境中作为PcntlController的回退控制器。