Scalr\System\Zmq\Cron\Launcher::healthcheck PHP Method

healthcheck() public static method

Performs health chek
public static healthcheck ( )
    public static function healthcheck()
    {
        //Verifying whether broker is running and starting broker if not.
        $healthy = self::ensureBrokerRunning();
        if (!$healthy) {
            //Waiting while broker is up
            sleep(2);
            //Retrying to check status
            $healthy = self::ensureBrokerRunning();
        }
        if (!$healthy) {
            //Could not start broker
            throw new Exception("Could not start 0MQ MDP Broker");
        }
    }

Usage Example

Esempio n. 1
0
 if ($startTime->format('i') == $previous->format('i')) {
     //Sleep interval, first sleep will be long
     sleep(isset($sleep) ? 1 : 60 - $startTime->format('i'));
     unset($startTime);
     //Next sleeps will be shorter
     $sleep = true;
     continue;
 }
 //Update previous start time with current
 unset($previous);
 $previous = $startTime;
 try {
     //Initializes task factory
     $launcher = new Launcher($startTime);
     //Performs health check at each start
     Launcher::healthcheck();
     $launcher->setLogger($logger)->launch();
 } catch (ZMQException $e) {
     if ($e->getCode() == 4) {
         //Catches ETERM
         $interrupt++;
         usleep(1);
         break;
     }
     $logger->fatal("Launcher error: %s", $e->getMessage());
 }
 //Release resources
 unset($launcher);
 unset($startTime);
 unset($sleep);
 if ($previous->format('i') % 5 === 0) {