Created
April 20, 2017 16:48
-
-
Save kil9/af2455d4cf82a5494cd67ed44c6627a5 to your computer and use it in GitHub Desktop.
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/sh | |
# source function library | |
. /etc/init.d/functions | |
APP_NAME='app-server-go' | |
APP_HOME="`dirname "$0"`/.." | |
APP_HOME=`cd "${APP_HOME}" > /dev/null; pwd` | |
cd ${APP_HOME} | |
APP=${APP_HOME}/${APP_NAME} | |
LOG_FILE=${APP_HOME}/var/logs/${APP_NAME}.log | |
PID_FILE=${APP_HOME}/var/pids/${APP_NAME}.pid | |
GOMAXPROCS=40 | |
function start { | |
echo "Running ${APP_NAME}" | |
nohup ${APP} >> ${LOG_FILE} 2>&1 & | |
echo $! > ${PID_FILE} | |
} | |
function stop() { | |
PIDFILES=$(find ${APP_HOME}/var/pids -type f -name ${APP_NAME}*.pid) | |
for pidfile in $PIDFILES; do | |
echo -n ${pidfile} | |
killproc -p ${pidfile} ${APP} | |
echo | |
done | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
status ${APP} | |
;; | |
restart) | |
echo "restarting $APP_NAME..." | |
stop | |
sleep 1 | |
start | |
;; | |
status) | |
status ${APP} | |
;; | |
*) | |
echo "Usage: `basename $0` (start|stop|restart|status)" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment