A Bash script for graceful restarts
Provides a script template that:
- Stops a running process
- Gives the process a maximum time to terminate itself. With regular checks if this has already happend
- Kills the process (SIGKILL) if it refuses to stop after the maximum time
- Restarts the process
I build this script as part of a cronjob for restarting server processes. These processes take some time to stop and sometimes they refuse to stop at all.
The template is contained in restart.sh. Use this for you own script.
dummy.sh is a small script for testing restart.sh.
The script was developed under MacOS. Take a look at the hints in restart.sh and do some tests with dummy.sh before deploying into production.