You are here

public function BackgroundProcess::setServiceHost in Background Process 7.2

Set current service host.

Parameters

optional $service_host: Service host to use. If invalid or none specified, the default service host will be used.

1 call to BackgroundProcess::setServiceHost()
BackgroundProcess::setServiceGroup in ./background_process.inc
Set the service group. This method sets the service host based on the service group.

File

./background_process.inc, line 402
External API short overview

Class

BackgroundProcess
@file

Code

public function setServiceHost($service_host = NULL) {
  $this
    ->ensureProcess();
  $service_hosts = background_process_get_service_hosts();
  if (!$service_host || empty($service_hosts[$service_host])) {

    // Invalid service hosts selected!
    $service_host = variable_get('background_process_default_service_host', 'default');
  }
  if ($service_hosts[$service_host]['max_clients'] > 0) {
    $clients = background_process_current_clients($service_host);
    if ($service_hosts[$service_host]['max_clients'] <= $clients) {
      $this
        ->keepAlive(FALSE)
        ->remove();
      throw new BackgroundProcessException(t('Max clients limit reached'), BACKGROUND_PROCESS_ERROR_LIMIT_REACHED);
    }
  }
  $this->service_host = $service_host;
  $this->dirty['service_host'] = $this->service_host;
  $this
    ->setDispatcher($service_hosts[$service_host]['dispatcher']);
  return $this;
}