Skip to content

Commit

Permalink
MDL-65229 cron: Add cli option --stop to notify all cron to stop
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Dec 3, 2019
1 parent 800563e commit 0bcc273
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions admin/cli/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@
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);
Expand All @@ -49,6 +57,7 @@
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
Expand All @@ -58,4 +67,11 @@
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();
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0bcc273

Please sign in to comment.