MDL-65229 cron: Add cli option --stop to notify all cron to stop

This commit is contained in:
Brendan Heywood 2019-10-16 10:47:53 +11:00
parent 800563e415
commit 0bcc273f63
2 changed files with 19 additions and 2 deletions

View File

@ -35,8 +35,16 @@ require_once($CFG->libdir.'/clilib.php'); // cli only functions
require_once($CFG->libdir.'/cronlib.php');
// now get cli options
list($options, $unrecognized) = cli_get_params(array('help'=>false),
array('h'=>'help'));
list($options, $unrecognized) = cli_get_params(
array(
'help' => false,
'stop' => false,
),
array(
'h' => 'help',
's' => 'stop',
)
);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
@ -49,6 +57,7 @@ if ($options['help']) {
Options:
-h, --help Print out this help
-s, --stop Notify all other running cron processes to stop after the current task
Example:
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
@ -58,4 +67,11 @@ Example:
die;
}
if ($options['stop']) {
// By clearing the caches this signals to other running processes
// to exit after finishing the current task.
\core\task\manager::clear_static_caches();
die;
}
cron_run();

View File

@ -2,6 +2,7 @@ This files describes API changes in core libraries and APIs,
information provided here is intended especially for developers.
=== 3.8 ===
* Add CLI option to notify all cron tasks to stop: admin/cli/cron.php --stop
* The rotate_image function has been added to the stored_file class (MDL-63349)
* The yui checknet module is removed. Call \core\session\manager::keepalive instead.
* The generate_uuid() function has been deprecated. Please use \core\uuid::generate() instead.