MDL-59594 cron: Allow graceful exit of cron and adhoc task cli's
This commit is contained in:
@@ -74,4 +74,6 @@ if ($options['stop']) {
|
||||
die;
|
||||
}
|
||||
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
|
||||
cron_run();
|
||||
|
||||
@@ -115,5 +115,7 @@ cron_setup_user();
|
||||
$humantimenow = date('r', time());
|
||||
$keepalive = (int)$options['keep-alive'];
|
||||
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
|
||||
mtrace("Server Time: {$humantimenow}\n");
|
||||
cron_run_adhoc_tasks(time(), $keepalive, $checklimits);
|
||||
|
||||
+4
-2
@@ -114,7 +114,8 @@ function cron_run_scheduled_tasks(int $timenow) {
|
||||
|
||||
// Run all scheduled tasks.
|
||||
try {
|
||||
while (!\core\task\manager::static_caches_cleared_since($timenow) &&
|
||||
while (!\core\local\cli\shutdown::should_gracefully_exit() &&
|
||||
!\core\task\manager::static_caches_cleared_since($timenow) &&
|
||||
$task = \core\task\manager::get_next_scheduled_task($timenow)) {
|
||||
cron_run_inner_scheduled_task($task);
|
||||
unset($task);
|
||||
@@ -167,7 +168,8 @@ function cron_run_adhoc_tasks(int $timenow, $keepalive = 0, $checklimits = true)
|
||||
$taskcount = 0;
|
||||
|
||||
// Run all adhoc tasks.
|
||||
while (!\core\task\manager::static_caches_cleared_since($timenow)) {
|
||||
while (!\core\local\cli\shutdown::should_gracefully_exit() &&
|
||||
!\core\task\manager::static_caches_cleared_since($timenow)) {
|
||||
|
||||
if ($checklimits && (time() - $timenow) >= $maxruntime) {
|
||||
if ($waiting) {
|
||||
|
||||
Reference in New Issue
Block a user