function hosting_task_execute in Hosting 7.3
Same name and namespace in other branches
- 7.4 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 759 - Web server node type is defined here.
Code
function hosting_task_execute($task, $backend_options = array()) {
// Log in watchdog and drush.
watchdog('hosting_task', 'Starting task "@title" [node/@nid].', array(
'@title' => $task->title,
'@nid' => $task->nid,
), WATCHDOG_NOTICE, url("node/{$task->nid}"));
drush_log(dt('Starting task "@title" [node/@nid].', array(
'@title' => $task->title,
'@nid' => $task->nid,
)), '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. [node/@nid]', array(
'@title' => $task->title,
'@nid' => $task->nid,
)), 'ok');
}
else {
$task = node_load($task->nid, NULL, TRUE);
drush_log(dt('Finished task "@title" with status "@status" in @duration [node/@nid].', array(
'@title' => $task->title,
'@nid' => $task->nid,
'@status' => _hosting_parse_error_code($task->task_status),
'@duration' => format_interval($task->delta, 1),
)), 'ok');
}
}