Scalr\Upgrade\UpgradeHandler::checkPid PHP Метод

checkPid() публичный статический Метод

Checks and creates pid file
public static checkPid ( ) : boolean
Результат boolean Returns false if process has already been started or creates a new pid file
    public static function checkPid()
    {
        $dbScalr = \Scalr::getContainer()->adodb;
        if (file_exists(UPGRADE_PID_FILEPATH) && ($pid = file_get_contents(UPGRADE_PID_FILEPATH)) > 0 && !self::isOutdatedPid(trim($pid))) {
            return false;
        }
        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 check pid file for %s service\n", $p[0]);
                continue;
            }
            if ($db->getOne("SHOW TABLES FROM `" . $database . "` LIKE ?", ['settings'])) {
                if (($pid = call_user_func($p[1] . '::getValue', SettingEntity::ID_UPGRADE_PID)) > 0 && !self::isOutdatedPid($pid)) {
                    return false;
                }
                call_user_func($p[1] . '::setValue', SettingEntity::ID_UPGRADE_PID, time());
            }
        }
        file_put_contents(UPGRADE_PID_FILEPATH, time());
        chmod(UPGRADE_PID_FILEPATH, 0666);
        return true;
    }