public function start() : int
    {
        $pathToServerScript = $this->config['server_path'];
        if (!file_exists($pathToServerScript)) {
            throw new ControlException('Server script not found. Check server_path in your config file.');
        }

        // check if process is already running:
        $serverPid = $this->getServerPid();
        if ($serverPid !== 0) {
            return $serverPid;
        }

        // startup server:
        $phpPath = $this->config['php_path'];
        $startupCommand = escapeshellcmd($phpPath . ' ' . $pathToServerScript) . ' > /dev/null 2>&1 &';
        exec($startupCommand);

        // return process id:
        $pid = $this->getServerPid();
        if (empty($pid)) {
            throw new ControlException('Could not start server. (Empty Pid)');
        }
        return $pid;
    }
public function start() : int
    {
        $pathToServerScript = $this->config['server_path'];
        if (!file_exists($pathToServerScript)) {
            throw new ControlException('Server script not found. Check server_path in your config file.');
        }

        // check if process is already running:
        $serverPid = $this->getServerPid();
        if ($serverPid !== 0) {
            return $serverPid;
        }

        // startup server:
        $phpPath = $this->config['php_path'];
        $startupCommand = escapeshellcmd($phpPath . ' ' . $pathToServerScript) . ' > /dev/null 2>&1 &';
        exec($startupCommand);

        // return process id:
        $pid = $this->getServerPid();
        if (empty($pid)) {
            throw new ControlException('Could not start server. (Empty Pid)');
        }
        return $pid;
    }
public function start ( ) : int { $ pathToServerScript = $ this -> config [ 'server_path' ] ; if ( ! file_exists ( $ pathToServerScript ) ) { throw new ControlException ( 'Server script not found. Check server_path in your config file.' ) ; } // check if process is already running: $ serverPid = $ this -> getServerPid ( ) ; if ( $ serverPid !== 0 ) { return $ serverPid ; } // startup server: $ phpPath = $ this -> config [ 'php_path' ] ; $ startupCommand = escapeshellcmd ( $ phpPath . ' ' . $ pathToServerScript ) . ' > /dev/null 2>&1 &' ; exec ( $ startupCommand ) ; // return process id: $ pid = $ this -> getServerPid ( ) ; if ( empty ( $ pid ) ) { throw new ControlException ( 'Could not start server. (Empty Pid)' ) ; } return $ pid ; }
Starts Server instance as a background process.

@throws ControlException
@return int Process id (0 if script could not be started).
Starts Server instance as a background process .