function hosting_task_execute in Hosting 7.4
Same name and namespace in other branches
- 7.3 task/hosting_task.module \hosting_task_execute()
Executes a task while logging to watchdog and drush. Implemented by drush hosting-tasks and hosting-queued commands.
Parameters
$task: A fully loaded task node.
$backend_options: @see drush_invoke_process().
2 calls to hosting_task_execute()
- drush_hosting_queued in queued/
hosting_queued.drush.inc - Drush command to execute hosting tasks.
- hosting_tasks_queue in task/
hosting_task.module - Process the hosting task queue.
File
- task/
hosting_task.module, line 784 - Web server node type is defined here.
Code
function hosting_task_execute($task, $backend_options = array()) {
// Log in watchdog and drush.
$t = array(
'@title' => $task->title,
'@nid' => $task->nid,
'@url' => url("node/{$task->nid}", array(
'absolute' => true,
)),
);
watchdog('hosting_task', 'Starting task "@title": @url', $t, WATCHDOG_NOTICE, url("node/{$task->nid}"));
drush_log(dt('Starting task "@title": @url', $t), 'ok');
// Execute in it's own process.
drush_invoke_process('@self', "hosting-task", array(
$task->nid,
), array(
'strict' => FALSE,
), $backend_options);
// Log a message, depending on forked process or not.
// If forked, the process may not have completed yet, so we should change the message.
if (isset($backend_options['fork']) && $backend_options['fork']) {
drush_log(dt('Launched task "@title" in a forked process: @url', $t), 'ok');
}
else {
$task = node_load($task->nid, NULL, TRUE);
$t['@status'] = _hosting_parse_error_code($task->task_status);
$t['@duration'] = format_interval($task->delta, 1);
drush_log(dt('Finished task "@title" with status "@status" in @duration: @url', $t), 'ok');
}
}