Tripal
|
Functions | |
tripal_get_job ($job_id) | |
tripal_add_job ($job_name, $modulename, $callback, $arguments, $uid, $priority=10, $includes=[], $ignore_duplicate=FALSE) | |
tripal_is_job_running () | |
tripal_max_jobs_exceeded ($max_jobs) | |
tripal_rerun_job ($job_id, $goto_jobs_page=NULL) | |
tripal_cancel_job ($job_id, $redirect=NULL) | |
tripal_launch_job ($do_parallel=0, $job_id=NULL, $max_jobs=-1, $single=0) | |
tripal_set_job_progress ($job_id, $percentage) | |
tripal_get_job_progress ($job_id) | |
tripal_get_active_jobs ($modulename=NULL) | |
tripal_execute_job ($job_id, $redirect=TRUE) | |
Tripal offers a job management subsystem for managing tasks that may require an extended period of time for completion. Tripal provides several administrative tasks that may time out and not complete due to limitations of the web server. To circumvent this, as well as provide more fine-grained control and monitoring, Tripal uses a jobs management system.
The Tripal jobs management system allows administrators to submit tasks to be performed which can then be launched through a UNIX command-line PHP script or cron job. This command-line script can be added to a cron entry along-side the Drupal cron entry for automatic, regular launching of Tripal jobs. The order of execution of waiting jobs is determined first by priority and second by the order the jobs were entered.
tripal_add_job | ( | $job_name, | |
$modulename, | |||
$callback, | |||
$arguments, | |||
$uid, | |||
$priority = 10 , |
|||
$includes = [] , |
|||
$ignore_duplicate = FALSE |
|||
) |
Adds a job to the Tripal Job queue
$job_name | The human readable name for the job |
$modulename | The name of the module adding the job |
$callback | The name of a function to be called when the job is executed |
$arguments | An array of arguments to be passed on to the callback |
$uid | The uid of the user adding the job |
$priority | The priority at which to run the job where the highest priority is 10 and the lowest priority is 1. The default priority is 10. |
$includes | An array of paths to files that should be included in order to execute the job. Use the module_load_include function to get a path for a given file. |
$ignore_duplicate | . Set to TRUE to not add the job if it has the same name as another job which has not yet run. The default is TRUE. |
Example usage:
The code above is copied from the tripal_feature/fasta_loader.php file. The snipped first builds an array of arguments that will then be passed to the tripal_add_job function. The number of arguments provided in the $arguments variable should match the argument set for the callback function provided as the third argument.
tripal_cancel_job | ( | $job_id, | |
$redirect = NULL |
|||
) |
Cancel a Tripal Job currently waiting in the job queue.
$job_id | The job_id of the job to be cancelled |
$redirect | DEPRECATED |
tripal_execute_job | ( | $job_id, | |
$redirect = TRUE |
|||
) |
Execute a specific Tripal Job.
$job_id | The job id to be exeuted. |
$redirect | DEPRECATED |
tripal_get_active_jobs | ( | $modulename = NULL | ) |
Returns a list of jobs that are active.
$modulename | Limit the list returned to those that were added by a specific module. If no module name is provided then all active jobs are returned. |
tripal_get_job | ( | $job_id | ) |
DEPRECATED
Use the TripalJob::load function instead
Retrieve information regarding a tripal job
$job_id | The unique identifier of the job |
tripal_get_job_progress | ( | $job_id | ) |
Retrieves the current proress of a job.
$job_id | The job_id to get the progress for |
tripal_is_job_running | ( | ) |
Indicates if any jobs are running.
This function will check the system to see if a job has a process ID and if that process ID is still running. It will update the job status accordingly before returning.
tripal_launch_job | ( | $do_parallel = 0 , |
|
$job_id = NULL , |
|||
$max_jobs = -1 , |
|||
$single = 0 |
|||
) |
A function used to manually launch all queued tripal jobs.
$do_parallel | A boolean indicating whether jobs should be attempted to run in parallel |
$job_id | To launch a specific job provide the job id. This option should be used sparingly as the jobs queue managment system should launch jobs based on order and priority. However there are times when a specific job needs to be launched and this argument will allow it. Only jobs which have not been run previously will run. |
$max_jobs | The maximum number of jobs that should be run concurrently. If -1 then unlimited. |
$single | Ensures only a single job is run rather then the entire queue. |
tripal_max_jobs_exceeded | ( | $max_jobs | ) |
Check for too many concurrent jobs.
$max_jobs | The maximum number of concurrent jobs to allow; -1 = no limit |
tripal_rerun_job | ( | $job_id, | |
$goto_jobs_page = NULL |
|||
) |
Set a job to be re-run (ie: add it back into the job queue).
$job_id | The job_id of the job to be re-ran |
$goto_jobs_page | DEPRECATED If set to TRUE then after the re run job is added Drupal will redirect to the jobs page |
tripal_set_job_progress | ( | $job_id, | |
$percentage | |||
) |
An internal function for setting the progress for a current job.
$job_id | The job_id to set the progress for |
$percentage | The progress to set the job to |