Introduce cron_shutdown function for stopping the main background worker #381
+86
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Normally the main background worker used to start tasks cannot be stopped, because it always auto restarts.
This change introduces SQL function
cron_shutdown
that can be used to stop the background worker.It works by creating a shared memory that holds pid of the main background worker and bool flag specifying whether to restart the worker. By default, this keeps the current behaviour of automatically restarting the worker whenever it's killed. In situations when the user actually wants the main worker to be killed, It gives a way to do it.
This currently doesn't stop any other worker started by the scheduler.
The change that introduced auto-restarts is #286
Fixes #352