public function UltimateCronSerialLauncher::launchPoorman in Ultimate Cron 7.2
Poormans cron launcher.
File
- plugins/
ultimate_cron/ launcher/ serial.class.php, line 384 - Serial cron job launcher for Ultimate Cron.
Class
- UltimateCronSerialLauncher
- Ultimate Cron launcher plugin class.
Code
public function launchPoorman() {
$class = _ultimate_cron_get_class('lock');
$settings = $this
->getDefaultSettings();
// Is it time to run cron?
$cron_last = variable_get('cron_last', 0);
$cron_next = floor(($cron_last + 60) / 60) * 60;
$time = time();
if ($time < $cron_next) {
if ($settings['poorman_keepalive'] && ($lock_id = $class::lock('ultimate_cron_poorman_serial', 60))) {
ultimate_cron_poorman_page_flush();
$sleep = $cron_next - $time;
sleep($sleep);
ultimate_cron_poorman_trigger();
$class::unLock($lock_id);
}
return;
}
unset($_GET['thread']);
ultimate_cron_poorman_page_flush();
ultimate_cron_run_launchers();
// Check poorman settings. If launcher has changed, we don't want
// to keepalive.
$poorman = _ultimate_cron_plugin_load('settings', 'poorman');
if (!$poorman) {
return;
}
$settings = $poorman
->getDefaultSettings();
if (!$settings['launcher'] || $settings['launcher'] !== $this->name) {
return;
}
$settings = $this
->getDefaultSettings();
if ($settings['poorman_keepalive'] && ($lock_id = $class::lock('ultimate_cron_poorman_serial', 60))) {
// Is it time to run cron? If not wait before re-launching.
$cron_last = variable_get('cron_last', 0);
$cron_next = floor(($cron_last + 60) / 60) * 60;
$time = time();
if ($time < $cron_next) {
$sleep = $cron_next - $time;
sleep($sleep);
}
$class::unLock($lock_id);
ultimate_cron_poorman_trigger();
}
}