So I have a custom in-house app developed by a 3rd party. When the app is running, I can verify it is running with the "screen -ls" command. As long as screens are running for rails and freeswitch then I know the app is properly up and running.
We have a specific bash script to stop the services related to the app, and 2nd script to start the services related to the app.
My question is how can I combine both these scripts to restart the app into 1 script that works like the following:
- Run script 1 - stop app
- Wait until app has shutdown (screen processes are no longer running)
- Run script 2 - start app
- Wait until app has started
- Check "screen" sockets to make sure a rails and freeswitch process is running. If not, then go back to step 1 and repeat.
Right now to restart the app:
- I manually run the stop script via /tools/stop_app.sh
- This then outputs to the terminal to show services shutting down.
- Once complete, it returns me back to the terminal prompt.
- Now I manually run the start script via /tools/start_app.sh
- This doesn't output anything, but once it has completed it returns me to the terminal prompt.
- I then run screen -ls to verify all services for the app is running. (sometimes a service such as freeswitch doesn't start.)
- If not, then I re-run the stop/start scripts.
It might be asked why don't I just put everything into one script. Well this custom app is very finicky and due to limited support from the developers, we need to make sure to utilize the exact tools they provided. Hence 1 script that calls the 2 separate scripts provided by the developers.
By integrity check I am referring to checking the "screen" processes to make sure that the ruby and freeswitch screens are running. For the cron, I would like to perform this app restart automatically on a weekly basis.
Note, when I say bash script I am not sure if it correct to say bash or shell. I have no script preference as long as it is a language that usually comes installed by default in Ubuntu Linux.