You are here

function drush_hosting_hosting_task in Hosting 5

File

./task.hosting.inc, line 46

Code

function drush_hosting_hosting_task() {
  $task =& drush_get_context('HOSTING_TASK');
  $hostname = null;
  $username = null;
  if (isset($task->options['web_id']) && $task->options['web_id'] != HOSTING_OWN_WEB_SERVER) {
    $username = $task->options['script_user'];
    $hostname = $task->options['web_host'];
  }
  $drush_path = $task->options['drush_path'];
  $task->options['root'] = $task->options['publish_path'];

  // make sure argument order is correct
  ksort($task->args);
  $data = array_merge($task->args, $task->options);
  $data['uri'] = null;

  // provision commands do not need the url passed to them.
  $mode = drush_get_option('debug', FALSE) ? 'GET' : 'POST';
  $output = drush_backend_invoke("provision " . $task->task_type, $data, $mode, TRUE, $drush_path, $hostname, $username);
  drush_set_context('HOSTING_DRUSH_OUTPUT', $output);
  $code = drush_get_error();

  // record status
  // We return 0 on success, so anything else is an error.
  $task->task_status = $code ? HOSTING_TASK_ERROR : HOSTING_TASK_SUCCESS;
  $task->queued = 0;

  // New revision is created at the beginning of function.
  $task->revision = false;
  node_save($task);
  drush_log(dt("Removing task from hosting queue"), 'queue');
}