AppserverIo\Appserver\Core\Scanner\AbstractScanner::getRestartCommand PHP Метод

getRestartCommand() публичный Метод

Returns the restart command for the passed OS if available.
public getRestartCommand ( string $os, string | null $distVersion = null ) : string
$os string The OS to return the restart command for
$distVersion string | null Version of the operating system to get the restart command for
Результат string The restart command
    public function getRestartCommand($os, $distVersion = null)
    {
        // check if the restart command is registered
        if (array_key_exists($os, $this->restartCommands)) {
            // check whether or not we got an array, if so we have to check for the version
            $command = $this->restartCommands[$os];
            if (is_array($command)) {
                // if we do have a certain version we have to determine the command
                if (!is_null($distVersion)) {
                    // floor the dist version for comparison
                    $distVersion = (int) floor((double) $distVersion);
                    foreach ($command as $version => $potentialCommand) {
                        if ($distVersion === $version) {
                            $command = $potentialCommand;
                            break;
                        }
                    }
                }
                // if we did not find anything we have to take the default command
                if (is_array($command)) {
                    $command = $command['default'];
                }
            }
            // for Mac OS X the base directory has to be appended
            if ($os === DeploymentScanner::DARWIN) {
                $command = $this->getService()->realpath($command);
            }
            // return the command
            return $command;
        }
        // throw an exception if the restart command is not available
        throw new \Exception("Can't find restart command for OS {$os}");
    }