Created
April 5, 2012 12:41
-
-
Save oberhamsi/2310782 to your computer and use it in GitHub Desktop.
openshift start/stop scripts
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 | |
| # The application will work only if it binds to | |
| # $OPENSHIFT_INTERNAL_IP:8080 | |
| RUN_CMD="${OPENSHIFT_REPO_DIR}ringojs/bin/ringo" | |
| RUN_ARGS="${OPENSHIFT_REPO_DIR}nocms/main.js serve ${OPENSHIFT_REPO_DIR}foo/" | |
| RINGO_PID="${OPENSHIFT_DATA_DIR}ringo.pid" | |
| RINGO_LOG="${OPENSHIFT_LOG_DIR}ringo.log" | |
| echo -n "Starting: " | |
| if [ -f $RINGO_PID ]; then | |
| echo "RingoJs (pid `cat $RINGO_PID`) already running" | |
| exit 0 | |
| fi | |
| nohup $RUN_CMD $RUN_ARGS > $RINGO_LOG 2>&1 & | |
| echo $! > $RINGO_PID | |
| echo "RingoJs (pid `cat $RINGO_PID`) started." |
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 | |
| RINGO_PID="${OPENSHIFT_DATA_DIR}ringo.pid" | |
| RINGO_LOG="${OPENSHIFT_LOG_DIR}ringo.log" | |
| echo -n "Shutting down: " | |
| if [ ! -f $RINGO_PID ]; then | |
| echo "RingoJs not running" | |
| exit 0 | |
| fi | |
| PID=`cat $RINGO_PID 2>/dev/null` | |
| echo -n "RingoJs (pid $PID) " | |
| CNT=0 | |
| kill $PID 2>/dev/null; | |
| # wait for max. 20 seconds to finish | |
| while [[ -e /proc/$PID && $CNT -lt 20 ]]; do | |
| echo -n "." | |
| let CNT=CNT+1 | |
| sleep 1 | |
| done | |
| # kill the process if it's still running | |
| if [ -e /proc/$PID ]; then | |
| echo " KILLING PROCESS!" | |
| kill -9 $PID 2>/dev/null | |
| else | |
| echo " stopped successfully" | |
| fi | |
| rm -f $RINGO_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment