You are here

function drush_ultimate_cron_cron_unlock in Ultimate Cron 6

Same name and namespace in other branches
  1. 8.2 ultimate_cron.drush.inc \drush_ultimate_cron_cron_unlock()
  2. 8 ultimate_cron.drush.inc \drush_ultimate_cron_cron_unlock()
  3. 7.2 ultimate_cron.drush.inc \drush_ultimate_cron_cron_unlock()
  4. 7 ultimate_cron.drush.inc \drush_ultimate_cron_cron_unlock()

Unlock a cron job

File

./ultimate_cron.drush.inc, line 346
Drush commands for Ultimate Cron!

Code

function drush_ultimate_cron_cron_unlock($function) {
  $hooks = ultimate_cron_get_hooks();
  if (!isset($hooks[$function])) {
    return drush_set_error(dt('"!function" not found', array(
      '!function' => $function,
    )));
  }
  $handle_prefix = variable_get('ultimate_cron_handle_prefix', ULTIMATE_CRON_HANDLE_PREFIX);
  $handle = $handle_prefix . $function;
  if ($process = background_process_get_process($handle)) {

    // Unlock the process
    if (background_process_remove_process($process->handle, $process->start)) {
      drush_print(dt('Process for !function unlocked (process handle: !handle)', array(
        '!handle' => $handle,
        '!function' => $function,
      )));
      module_invoke_all('background_process_shutdown', $process, FALSE, t('Manually unlocked'));
    }
  }
  else {
    drush_set_error(dt('Process for !function not found (process handle: !handle)', array(
      '!handle' => $handle,
      '!function' => $function,
    )));
  }
}