Prose\UsingHost::startInScreen PHP Method

startInScreen() public method

public startInScreen ( $sessionName, $commandLine )
    public function startInScreen($sessionName, $commandLine)
    {
        // what are we doing?
        $log = usingLog()->startAction("start screen session '{$sessionName}' ({$commandLine}) on host '{$this->args[0]}'");
        // do we already have this session running on the host?
        expectsHost($this->args[0])->screenIsNotRunning($sessionName);
        // build up our command to run
        $commandLine = 'screen -L -d -m -S "' . $sessionName . '" bash -c "' . $commandLine . '"';
        // run our command
        //
        // this creates a detached screen session called $sessionName
        $this->runCommand($commandLine);
        // find the PID of the screen session, for future use
        $sessionDetails = fromHost($this->args[0])->getScreenSessionDetails($sessionName);
        // did the process start, or has it already terminated?
        if (empty($sessionDetails->pid)) {
            $log->endAction("session failed to start, or command exited quickly");
            throw new E5xx_ActionFailed(__METHOD__, "failed to start session '{$sessionName}'");
        }
        // all done
        $log->endAction("session running as PID {$sessionDetails->pid}");
    }