Automattic / Cron-Control

A fresh take on running WordPress's cron system, allowing parallel processing

Home Page:https://wordpress.org/plugins/wp-cron-control/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perform graceful shutdown of the runner on SIGINT/SIGTERM

darthhexx opened this issue · comments

To ensure we don't leave things half done, we need to catch the signal, set a variable and then check it in our main loop for the exit condition.

I looked at this, and as I recall, Go passed the signal down to any child processes even when it was caught. This meant that even if the runner caught the signal, any running WP-CLI process responded to the signal.

I added the option to disable execution to deal with this situation. It's a per-site option, but if one needed to shutdown all execution, one could filter the a8c_cron_control_disable_run option to return 1:

const DISABLE_RUN_OPTION = 'a8c_cron_control_disable_run';
.

@ethitter what do you think of PR #154? Seems to work as expected although I haven't tested it with an actual long running CLI job.