-
-
Notifications
You must be signed in to change notification settings - Fork 947
Signals
This page explains how to use signals to gracefully shut down background process.
When you start the background processing with Background.Run(Handler), it will block and wait for incoming signals.
There are two types of signals you can send to the running program to gracefully shutdown the background processing.
-
TSTP : This signal tells
Backgroundto stop processing new tasks. -
TERM or INT : This signal tells
Backgroundto terminate.
It's recommended that you first send TSTP signal to stop processing new tasks and wait for all in-progress tasks to finish before sending TERM signal to terminate the program.
Use kill command to send signals.
kill -TSTP <pid> # stop processing new tasks
kill -TERM <pid> # terminate the programNote: If you send TERM or INT signal without sending TSTP signal, the Background will start a timer for 8 seconds to allow for all workers to finish. If there are workers that didn't finish within that time frame, the task will be transitioned back to enqueued state and will be processed once the program restarts.