Created
October 16, 2014 09:28
-
-
Save josteinaj/8377c756c8b66bdaa043 to your computer and use it in GitHub Desktop.
Linux bash script that can be used to keep Pipeline 2 running. It will start Pipeline 2 if it is not running, and kill it if it is not responding. You might need to install curl and screen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# Change APPDATA/ENGINE_HOME/WEBUI_HOME if necessary, | |
# and set this script up as a cron job, for instance: | |
# */1 * * * * $HOME/pipeline-watchdog.sh >/tmp/pipeline-watchdog.log 2>&1 | |
PIPELINE_APPDATA="$HOME/.daisy-pipeline" | |
PIPELINE_ENGINE_HOME="$HOME/daisy-pipeline" | |
PIPELINE_WEBUI_HOME="$HOME/daisy-pipeline-webui" | |
curl http://localhost:8181/ws/alive | |
PIPELINE_ENGINE_RUNNING="$?" # 0 if running | |
PIPELINE_WEBUI_RUNNING="`screen -list | grep dp2-webui | wc -l`" # 1 if running | |
if [ "$PIPELINE_ENGINE_RUNNING" = "0" ] && [ "$PIPELINE_WEBUI_RUNNING" = "1" ] ; then | |
echo "Pipeline 2 (engine and Web UI) is running as expected" | |
else | |
echo "Pipeline 2 (engine or Web UI) is not running as expected" | |
echo "Killing any non-responding instances of Pipeline 2..." | |
screen -X -S dp2-webui kill | |
screen -X -S dp2-engine kill | |
killall -9 java | |
echo "Starting Pipeline 2 core engine..." | |
cd "$PIPELINE_ENGINE_HOME/bin/" | |
screen -dmS dp2-engine ./pipeline2 | |
echo "Starting Pipeline 2 Web UI..." | |
rm "$PIPELINE_APPDATA/webui/RUNNING_PID" | |
cd "$PIPELINE_WEBUI_HOME/" | |
screen -dmS dp2-webui ./start | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment