Пример #1
0
          AND `pid` IS NOT NULL
          AND `pid` NOT IN (' . Utility::fillArray($pids) . ')', $pids);
        if ($res) {
            $affectedRows += $res->rowCount();
        }
        // Delete cron process only when current time is ahead of start_time
        $res = Database::query('DELETE FROM `' . FRAMEWORK_COLLECTION_PROCESS . '`
        WHERE `type` = \'cron\'
          AND `pid` = 0
          AND `pid` NOT IN (' . Utility::fillArray($pids) . ')', $pids);
        if ($res) {
            $affectedRows += $res->rowCount();
        }
        // Clear pid of dead permanent process
        $res = Database::query('UPDATE `' . FRAMEWORK_COLLECTION_PROCESS . '` SET `pid` = NULL
        WHERE `type` = \'permanent\' AND `pid` IS NOT NULL AND `pid` NOT IN (' . Utility::fillArray($pids) . ')', $pids);
        if ($res) {
            $affectedRows += $res->rowCount();
        }
    }
    unset($res, $pids);
    if ($affectedRows) {
        Log::debug(sprintf('Process cleanup, %d processes removed.', $affectedRows));
    }
    die;
}
// Cron processes
if (@$opts['cron']) {
    Log::debug('Cron started process.');
    $scheduler = function ($schedule) {
        $nextTime = CronExpression::factory($schedule['schedule'])->getNextRunDate()->format('Y-m-d H:i:s');