You are here

function hosting_dispatch in Hosting 5

Main queue processing command for hostmaster.

This is a single command, which will (based on configuration) run all the other queue commands (cron, backup, tasks, stats). This is done so that there is only one cron job to configure, and allow the frequency of calls to be configured from the interface.

1 string reference to 'hosting_dispatch'
hosting_drush_command in ./hosting.drush.inc

File

./hosting.queues.inc, line 16

Code

function hosting_dispatch() {
  $now = mktime();
  variable_set("hosting_dispatch_last_run", $now);
  drush_log('hosting_dispatch', t("dispatching queues"));
  $platform = node_load(HOSTING_OWN_PLATFORM);
  $root = $platform->publish_path;
  if (variable_get('hosting_dispatch_enabled', false)) {
    $queues = hosting_get_queues();
    foreach ($queues as $queue => $info) {
      if ($info['enabled']) {
        if ($now - $info["last"] >= $info["calc_frequency"]) {
          drush_backend_fork("hosting", array(
            $queue,
            'items' => $info['calc_items'],
          ));
        }
        else {
          drush_log(dt("too early for queue @queue", array(
            '@queue' => $queue,
          )));
        }
      }
      else {
        drush_log(dt("queue @queue disabled", array(
          '@queue' => $queue,
        )));
      }
    }
  }
  else {
    drush_log(dt("dispatching disabled"));
  }
}