PHPDaemon\Core\Daemon::spawnMaster PHP Method

spawnMaster() public static method

Spawn a master process
public static spawnMaster ( ) : null | integer
return null | integer - success
    public static function spawnMaster()
    {
        Daemon::$masters->push($thread = new Thread\Master());
        $thread->start();
        if (-1 === $thread->getPid()) {
            Daemon::log('could not start master');
            exit(0);
        }
        return $thread->getPid();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Start master.
  * @return void
  */
 public static function start()
 {
     if (Bootstrap::$pid && Thread\Generic::ifExistsByPid(Bootstrap::$pid)) {
         Daemon::log('[START] phpDaemon with pid-file \'' . Daemon::$config->pidfile->value . '\' is running already (PID ' . Bootstrap::$pid . ')');
         exit(6);
     }
     Daemon::init();
     $pid = Daemon::spawnMaster();
     file_put_contents(Daemon::$config->pidfile->value, $pid);
 }