job_scheduler_waiting.drush.inc in Job Scheduler 8.3
Command-line tools to aid performing and developing migrations.
File
modules/job_scheduler_waiting/job_scheduler_waiting.drush.incView source
<?php
/**
* @file
* Command-line tools to aid performing and developing migrations.
*/
/**
* Implements hook_drush_command().
*/
function job_scheduler_waiting_drush_command() {
$items['job-scheduler-waiting-perform'] = [
'description' => 'Perform the named, waiting the job schedule.',
'arguments' => [
'name' => 'Name of the job to perform.',
],
'drupal dependencies' => [
'job_scheduler_waiting',
],
'aliases' => [
'jswp',
],
];
return $items;
}
/**
* Performs a job.
*/
function drush_job_scheduler_waiting_perform($name = '') {
if (!$name) {
drush_set_error('JOB_ERROR', dt('You must specify name of the job.'));
return;
}
job_scheduler_waiting_perform_job($name);
}
/**
* Performs the named job with no timeout.
*
* @param string $name
* The name of the job to work with.
*/
function job_scheduler_waiting_perform_job($name) {
set_time_limit(0);
while (TRUE) {
$timer = microtime(true);
$scheduler = \Drupal::service('job_scheduler.manager');
$results = $scheduler
->perform($name);
if ($results['total']) {
$kernel = \Drupal::service('kernel');
$kernel
->rebuildContainer();
}
$timer = round(microtime(true) - $timer);
if ($timer < 1) {
sleep(1);
}
}
}
Functions
Name | Description |
---|---|
drush_job_scheduler_waiting_perform | Performs a job. |
job_scheduler_waiting_drush_command | Implements hook_drush_command(). |
job_scheduler_waiting_perform_job | Performs the named job with no timeout. |