Created
September 28, 2012 01:33
-
-
Save boris317/3797480 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| DIR=$( cd "$( dirname "$0" )" && pwd ) | |
| source $DIR/../env.sh | |
| if [ ! X_OPENSHIFT_RUNNING_LOCAL ]; then | |
| source $X_OPENSHIFT_VENV/bin/activate | |
| fi | |
| LOG_FILE="${OPENSHIFT_LOG_DIR}app.log" | |
| RUN_CMD="${OPENSHIFT_REPO_DIR}diy/run.py" | |
| echo "[start] Staring ${OPENSHIFT_APP_NAME}..." | |
| if [ -e $X_OPENSHIFT_PID_FILE ]; then | |
| echo "[start] Found pid file. App might already be running." | |
| $DIR/stop | |
| fi | |
| nohup $RUN_CMD > $LOG_FILE 2>&1 & | |
| PID=$! | |
| # This does not work as expected because $PID is ALWAYS in the process | |
| # list even if $RUN_CMD failed. When the script finally exits then $PID | |
| # no longers shows up in the process list. | |
| if [ -z "$(ps -ef | grep " $PID " | grep "run.py" | awk '{ print $2 }')" ] | |
| then | |
| echo "[start] Startup failed. Check ${LOG_FILE} for details." | |
| exit 1 | |
| else | |
| echo "[start] ${OPENSHIFT_APP_NAME} started. PID: ${PID}" | |
| echo $PID > $X_OPENSHIFT_PID_FILE | |
| exit 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment