Scalr\System\Zmq\Cron\Launcher::terminateBroker PHP Метод

terminateBroker() публичный статический Метод

Terminates broker
public static terminateBroker ( )
    public static function terminateBroker()
    {
        self::terminateByFilter(preg_replace('/^.+ php /', 'php ', self::getStartBrokerCommand()), false);
    }

Usage Example

Пример #1
0
//Signal handler callback function
$sigHandler = function ($signo = null) use(&$interrupt, $oPid, $logger) {
    static $once = 0;
    $interrupt++;
    if ($once++) {
        return;
    }
    //Reporting about termination
    $logger->log("SERVICE", "Service recieved termination SIGNAL:%d", intval($signo));
    //We should stop all running tasks.
    //It's enough to terminate all running clients.
    Launcher::terminateClients();
    //Without this workers may not be terminated
    sleep(1);
    //Terminating an MDP broker, not sure we have to do so.
    Launcher::terminateBroker();
    //Removing pid file
    $oPid->remove();
};
pcntl_signal(SIGINT, $sigHandler);
pcntl_signal(SIGTERM, $sigHandler);
pcntl_signal(SIGHUP, $sigHandler);
register_shutdown_function($sigHandler);
$previous = new DateTime('-5 minutes');
$logger->log("SERVICE", "Starting service");
while (!$interrupt) {
    // System tymezone is considered to be used here
    $startTime = new DateTime('now');
    //We run every minute
    if ($startTime->format('i') == $previous->format('i')) {
        //Sleep interval, first sleep will be long