1) Install this plugin just to make testing easier:
https://github.com/catalyst/moodle-tool_testtasks
git clone https://github.com/catalyst/moodle-tool_testtasks.git admin/tool/testtasks
|
2) Queue up 5 ad hoc tasks that each take 5 seconds to run:
php admin/tool/testtasks/cli/queue_adhoc_tasks.php -n=5 -d=5
|
3) Run the standalone ad hoc task processor:
php admin/tool/task/cli/adhoc_task.php --execute
|
4) Watch it for a little while, then press Control C, instead of immediately exiting it should gracefully finish what it was doing, and then exit instead of picking up it's next task:
== Exiting gracefully, please wait ... ==
|
5) Repeat the above, but press Control C twice, the second time it will do a hard exit.
6) Rinse and repeat with admin/cli/cron.php but you need to carefully kill it during both the scheduled tasks and the ad hoc tasks.
7) The tests above capture SIGINT, for completeness also re-test but instead of killing via Ctrl+C, open another terminal and kill is using:
kill [pid]
This should also result in the 'Exiting gracefully' message.