function ultimate_cron_run_hook_cli in Ultimate Cron 6
Same name and namespace in other branches
- 8 ultimate_cron.module \ultimate_cron_run_hook_cli()
- 7 ultimate_cron.module \ultimate_cron_run_hook_cli()
1 call to ultimate_cron_run_hook_cli()
- drush_ultimate_cron_cron_run in ./
ultimate_cron.drush.inc - Run cron job(s)
File
- ./
ultimate_cron.module, line 815 - @todo Add filter on overview page. @todo Add log view (with graph). @todo Make proper markup for overview page. @todo Refactor drush stuff, too many intimate relations with Background Process @todo Refactor Cron % offset stuff. Too mixed up and…
Code
function ultimate_cron_run_hook_cli($name, $hook) {
// Run the job in background
$result = NULL;
$handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
$handle = $handle_prefix . $name;
$process = new BackgroundProcess($handle);
// Always run cron job as anonymous user
$process->uid = 0;
$hook['timestamp'] = time();
if ($process
->lock()) {
try {
$process_obj = background_process_get_process($handle);
$process->start = $process_obj->start;
if (function_exists('background_process_update_status')) {
background_process_update_status($handle, BACKGROUND_PROCESS_STATUS_RUNNING);
}
else {
$process->start = db_result(db_query("SELECT start_stamp FROM {background_process} WHERE handle = '%s'", $handle));
db_query("UPDATE {background_process} SET exec_status = %d WHERE handle = '%s'", BACKGROUND_PROCESS_STATUS_RUNNING, $handle);
}
$old_handle = background_process_current_handle();
background_process_current_handle($handle);
_ultimate_cron_run_hook($name, $hook);
module_invoke_all('background_process_shutdown', $process);
background_process_current_handle($old_handle);
background_process_remove_process($handle, $process->start);
return TRUE;
} catch (Exception $e) {
module_invoke_all('background_process_shutdown', $process, (string) $e);
return NULL;
}
}
return FALSE;
}