I'm trying to write service script for application. So I can control it like this:
./myscript.sh start|stop|status
On startup pid.file
with process id creates, and based on it I can check status and stop process. In stop command I remove pid.file
- it's ok.
But if application crashes in abnormal way - power off, etc, pid.file
not removes and I need remove it manually.
How to properly handle this abnormal situations in script?