Offline job queues
The purpose of the offline jobs function is to delegate slow processes, such as creating a preview for a video file, to another script/process to be run asynchronously. The upload process therefore focuses on getting files into the filestore, later working from a queue for further processing.
Originally developed to work alongside the Video tracks plugin, job queue functionality has been expanded to allow the following to be handled offline:
- Creating an alternative file from the specified command
- Running a command that will create an output file, optionally specifying a download URL that can be sent to the user
- Creating previews for resources or alternative files
- Downloading collections of resources*
- Deleting files
- Extracting text from the resource and saving to a configured metadata field
* Please note that the offline jobs functionality for collection downloads is not available when ResourceSpace is accessed anonymously or via an externally shared collection
Offline jobs cannot be run individually by a user, they are run in the command line, usually using a regular cron job.
To enable this perform the following steps:-
- Enable a scheduled task (Windows) or cron job (Linux) that runs /pages/tools/offline_jobs.php as frequently as desired e.g.
*/5 * * * * cd /var/www/pages/tools; php offline_jobs.php
- Set the following option in the ResourceSpace configuration file (config.php)
Version 9.7 update
From version 9.7 and later the offline_jobs.php script can accept additional parameters as per the script help text output below (from running php offline_jobs.php --help). The --max-jobs can be useful to prevent many instances of the script from slowing a server down e.g. if a large amount of previews are being regenerated
SYNOPSIS php /path/to/pages/tools/tools/offline_jobs.php [OPTIONS...] DESCRIPTION Used to run ResourceSpace offline jobs. Normally trigggered by a cron entry/scheduled task. OPTIONS SUMMARY -h, --help Display this help text and exit -j, --job Specify the job ID to run -c, --clear-lock Clear any existing process locks for jobs -m, --max-jobs Maximum number of concurrent jobs that can be running (integer) EXAMPLES php offline_jobs.php --clear-lock --job 256 php offline_jobs.php --max-jobs 5