function background_process_ass_auto_unlock in Background Process 8
Same name and namespace in other branches
- 6 background_process_ass/background_process_ass.module \background_process_ass_auto_unlock()
- 7.2 background_process_ass/background_process_ass.module \background_process_ass_auto_unlock()
- 7 background_process_ass/background_process_ass.module \background_process_ass_auto_unlock()
Implements to Unlock locked processes that aren't really running.
1 call to background_process_ass_auto_unlock()
- background_process_ass_cron in background_process_ass/
background_process_ass.module - Implements hook_cron().
File
- background_process_ass/
background_process_ass.module, line 103 - Implements Background Process Ass Module. @todo Implement admin interface. @todo Fix runtime check of running process.
Code
function background_process_ass_auto_unlock() {
$processes = background_process_get_processes();
$service_hosts = background_process_get_service_hosts();
foreach ($processes as $process) {
if (!$process->service_host) {
continue;
}
// Host to use for server-status.
if (!isset($service_hosts[$process->service_host . '_ass'])) {
continue;
}
if (!isset($service_hosts[$process->service_host])) {
continue;
}
list($url, $headers) = background_process_build_request('bgp-start/' . rawurlencode($process->handle), $process->service_host);
$process->http_host = $headers['Host'];
// Locate our connection.
$url = parse_url($url);
$path = $url['path'] . (isset($url['query']) ? '?' . $url['query'] : '');
if (strlen("POST {$path}") > 64) {
continue;
}
if ($process->status != BACKGROUND_PROCESS_STATUS_RUNNING) {
// Not ready for unlock yet.
continue;
}
if ($process->start > time() - \Drupal::config('background_process_ass.settings')
->get('background_process_ass_max_age')) {
continue;
}
$server_status = background_process_ass_get_server_status($process->service_host . '_ass');
if ($server_status) {
if (!background_process_ass_check_process($process, $server_status, $path)) {
_background_process_ass_unlock($process);
}
}
}
}