Skip to content

Instantly share code, notes, and snippets.

@kil9
Created April 20, 2017 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kil9/af2455d4cf82a5494cd67ed44c6627a5 to your computer and use it in GitHub Desktop.
Save kil9/af2455d4cf82a5494cd67ed44c6627a5 to your computer and use it in GitHub Desktop.
#!/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