|
@@ -67,7 +67,8 @@ function tripal_drush_command() {
|
|
|
'description' => dt('Launches jobs waiting in the queue. Only one job can execute at a time unless the --parllel=1 option is provided.'),
|
|
|
'examples' => array(
|
|
|
'Single Job' => 'drush trp-run-jobs --username=administrator',
|
|
|
- 'Parallel Job' => 'drush trp-run-jobs --username=administrator --parallel=1'
|
|
|
+ 'Parallel Job' => 'drush trp-run-jobs --username=administrator --parallel=1',
|
|
|
+ 'Max-jobs Job' => 'drush trp-run-jobs --username=administrator --parallel=1 --max_jobs=10',
|
|
|
),
|
|
|
'arguments' => array(),
|
|
|
'options' => array(
|
|
@@ -79,13 +80,16 @@ function tripal_drush_command() {
|
|
|
),
|
|
|
'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
|
|
|
'job_id' => dt('Provide a job_id to run a specific job. Only jobs that have not been run already can be used'),
|
|
|
+ 'max_jobs' => dt('Indicate the maximum number of concurrent jobs. Default is -1 (unlimited). Ignore if not running parallel jobs'),
|
|
|
+ 'single' => dt('Execute only one queued job'),
|
|
|
),
|
|
|
);
|
|
|
$items['trp-rerun-job'] = array(
|
|
|
'description' => dt('Re-run a specific job from the queue.'),
|
|
|
'examples' => array(
|
|
|
'Single Job' => 'drush trp-rerun-job --username=administrator --job_id=2',
|
|
|
- 'Parallel Job' => 'drush trp-rerun-job --username=administrator --job_id=2 --parallel=1'
|
|
|
+ 'Parallel Job' => 'drush trp-rerun-job --username=administrator --job_id=2 --parallel=1',
|
|
|
+ 'Max-jobs Job' => 'drush trp-run-jobs --username=administrator --parallel=1 --max_jobs=10',
|
|
|
),
|
|
|
'arguments' => array(),
|
|
|
'options' => array(
|
|
@@ -100,6 +104,8 @@ function tripal_drush_command() {
|
|
|
'required' => TRUE,
|
|
|
),
|
|
|
'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
|
|
|
+ 'max_jobs' => dt('Indicate the maximum number of concurrent jobs. Default is -1 (unlimited). Ignore if not running parallel jobs'),
|
|
|
+ 'single' => dt('Execute only one queued job'),
|
|
|
),
|
|
|
);
|
|
|
|
|
@@ -140,6 +146,8 @@ function drush_tripal_set_user($username) {
|
|
|
function drush_tripal_trp_run_jobs() {
|
|
|
$parallel = drush_get_option('parallel');
|
|
|
$job_id = drush_get_option('job_id');
|
|
|
+ $max_jobs = drush_get_option('max_jobs', -1);
|
|
|
+ $single = drush_get_option('single', 0);
|
|
|
|
|
|
// Unfortunately later versions of Drush use the '--user' argument which
|
|
|
// makes it incompatible with how Tripal was using it. For backwards
|
|
@@ -160,17 +168,19 @@ function drush_tripal_trp_run_jobs() {
|
|
|
|
|
|
drush_tripal_set_user($username);
|
|
|
|
|
|
+ drush_print("\n" . date('Y-m-d H:i:s'));
|
|
|
if ($parallel) {
|
|
|
drush_print("Tripal Job Launcher (in parallel)");
|
|
|
+ if ($max_jobs !== -1) drush_print("Maximum number of jobs is " . $max_jobs);
|
|
|
drush_print("Running as user '$username'");
|
|
|
drush_print("-------------------");
|
|
|
- tripal_launch_job($parallel, $job_id);
|
|
|
+ tripal_launch_job($parallel, $job_id, $max_jobs, $single);
|
|
|
}
|
|
|
else {
|
|
|
drush_print("Tripal Job Launcher");
|
|
|
drush_print("Running as user '$username'");
|
|
|
drush_print("-------------------");
|
|
|
- tripal_launch_job(0, $job_id);
|
|
|
+ tripal_launch_job(0, $job_id, $max_jobs, $single);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -202,21 +212,24 @@ function drush_tripal_trp_rerun_job() {
|
|
|
|
|
|
$parallel = drush_get_option('parallel');
|
|
|
$job_id = drush_get_option('job_id');
|
|
|
+ $max_jobs = drush_get_option('max_jobs', -1);
|
|
|
+ $single = drush_get_option('single', 0);
|
|
|
|
|
|
drush_tripal_set_user($username);
|
|
|
$new_job_id = tripal_rerun_job($job_id, FALSE);
|
|
|
|
|
|
+ drush_print("\n" . date('Y-m-d H:i:s'));
|
|
|
if ($parallel) {
|
|
|
drush_print("Tripal Job Launcher (in parallel)");
|
|
|
drush_print("Running as user '$username'");
|
|
|
drush_print("-------------------");
|
|
|
- tripal_launch_job($parallel, $new_job_id);
|
|
|
+ tripal_launch_job($parallel, $new_job_id, $max_jobs, $single);
|
|
|
}
|
|
|
else {
|
|
|
drush_print("Tripal Job Launcher");
|
|
|
drush_print("Running as user '$username'");
|
|
|
drush_print("-------------------");
|
|
|
- tripal_launch_job(0, $new_job_id);
|
|
|
+ tripal_launch_job(0, $new_job_id, $max_jobs, $single);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -244,7 +257,8 @@ function drush_tripal_trp_get_currjob() {
|
|
|
"Module: " . $job->modulename . "\n" .
|
|
|
"Callback: " . $job->callback . "\n" .
|
|
|
"Process ID: " . $job->pid . "\n" .
|
|
|
- "Progress: " . $job->progress . "%\n";
|
|
|
+ "Progress: " . $job->progress . "%\n".
|
|
|
+ "Current Date: " . date('Y-m-d H:i:s') . "\n";
|
|
|
drush_print($output);
|
|
|
}
|
|
|
if (!$job_pid) {
|