run() public method

Runs upgrade process
public run ( ) : boolean
return boolean Returns true if all updates completed successfully, false otherwise
Beispiel #1
0
if (isset($opt['n']) || isset($opt['new'])) {
    $template = UpgradeHandler::getPathToUpdates() . '/Template.php';
    if (!is_readable($template)) {
        $console->error('Could not open template file for reading ' . $template);
        exit;
    }
    $released = gmdate('YmdHis');
    $pathname = UpgradeHandler::getPathToUpdates() . '/Update' . $released . '.php';
    $tpl = PhpTemplate::load($template, array('upd_released' => $released, 'upd_uuid' => \Scalr::GenerateUID()));
    if ($console->confirm("Are you sure you want to create a new upgrade class?")) {
        if (file_put_contents($pathname, $tpl) === false) {
            $console->error('Could not write to file "%s"', $pathname);
            exit;
        }
        $console->success('Upgrade class "%s" has been successfully created.', realpath($pathname));
    }
    exit;
}
if (isset($opt['force'])) {
    UpgradeHandler::removePid();
}
$upgrade = new UpgradeHandler($options);
if (!$upgrade->run()) {
    exit(1);
}
$scalrInfo = Scalr::getContainer()->version();
try {
    Scalr::getDb()->Execute("\n        REPLACE `scalr_hosts`\n        SET `host` = ?, `version` = ?, `edition` = ?, `git_commit` = ?, `git_commit_added` = ?\n    ", [php_uname("n"), $scalrInfo['version'], $scalrInfo['edition'], empty($scalrInfo['gitRevision']) ? null : $scalrInfo['gitRevision'], empty($scalrInfo['gitDate']) || ($gts = strtotime($scalrInfo['gitDate'])) === false ? null : date("Y-m-d H:i:s", $gts)]);
} catch (Exception $e) {
    Scalr::logException($e);
}
Beispiel #2
0
    if (!preg_match('/^[\\da-f]{32}$/i', $opt['r']) && !preg_match('/^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$/i', $opt['r'])) {
        $console->error("Error usage. UUID should be 32 hexadecimal digit number");
        $showusage();
    }
    $options->cmd = UpgradeHandler::CMD_RUN_SPECIFIC;
    $options->uuid = strtolower(str_replace('-', '', $opt['r']));
}
if (isset($opt['help']) || isset($opt['h'])) {
    $showusage();
}
if (isset($opt['n']) || isset($opt['new'])) {
    $template = UpgradeHandler::getPathToUpdates() . '/Template.php';
    if (!is_readable($template)) {
        $console->error('Could not open template file for reading ' . $template);
        exit;
    }
    $released = gmdate('YmdHis');
    $pathname = UpgradeHandler::getPathToUpdates() . '/Update' . $released . '.php';
    $tpl = PhpTemplate::load($template, array('upd_released' => $released, 'upd_uuid' => \Scalr::GenerateUID()));
    if ($console->confirm("Are you sure you want to create a new upgrade class?")) {
        if (file_put_contents($pathname, $tpl) === false) {
            $console->error('Could not write to file "%s"', $pathname);
            exit;
        }
        $console->success('Upgrade class "%s" has been successfully created.', realpath($pathname));
    }
    exit;
}
$upgrade = new UpgradeHandler($options);
$upgrade->run();