Scalr\Upgrade\UpgradeHandler::removePid PHP 메소드

removePid() 공개 정적인 메소드

Removes pid
public static removePid ( )
    public static function removePid()
    {
        if (file_exists(UPGRADE_PID_FILEPATH)) {
            unlink(UPGRADE_PID_FILEPATH);
        }
        //!TODO get rid of code duplication
        foreach ([['adodb', 'Scalr\\Model\\Entity\\SettingEntity'], ['cadb', 'Scalr\\Stats\\CostAnalytics\\Entity\\SettingEntity']] as $p) {
            if ($p[0] == 'cadb' && !\Scalr::getContainer()->analytics->enabled) {
                continue;
            }
            try {
                $db = \Scalr::getContainer()->{$p[0]};
                $database = $db->getOne("SELECT DATABASE()");
            } catch (\Exception $e) {
                printf("\nCould not remove pid file for %s service\n", $p[0]);
                continue;
            }
            if ($db->getOne("SHOW TABLES FROM `" . $database . "` LIKE ?", ['settings'])) {
                call_user_func($p[1] . '::setValue', SettingEntity::ID_UPGRADE_PID, null);
            }
        }
    }

Usage Example

예제 #1
0
파일: upgrade.php 프로젝트: scalr/scalr
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);
}