Skip to content

Instantly share code, notes, and snippets.

@guillochon
Last active April 22, 2018 18:15
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 guillochon/7148fe7a310cd4d08657f7e61c98dfe9 to your computer and use it in GitHub Desktop.
Save guillochon/7148fe7a310cd4d08657f7e61c98dfe9 to your computer and use it in GitHub Desktop.
OACAPI init.d
#!/bin/bash
#
# oacapi OACAPI server
#
# chkconfig: 345 70 30
# Source function library.
. /etc/init.d/functions
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/root/miniconda3/bin
DAEMON=gunicorn
LOCKFILE=/var/lock/subsys/oacapi
LOGFILE=/var/log/oacapi.log
PIDFILE=/var/run/oacapi.pid
PYTHONUNBUFFERED=TRUE
start() {
echo -n "Starting oacapi: "
source activate root
cd /root/OACAPI; $DAEMON --daemon --user=root --pid=$PIDFILE --bind 127.0.0.1:5000 --workers 1 --timeout 120 --log-file=$LOGFILE wsgi:app -k gthread --threads 10
RETVAL=$?
echo -n
[ $RETVAL = 0 ] && echo -e '[\e[32m OK \e[m]'
[ $RETVAL = 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
echo -n "Shutting down oacapi: "
killproc -p $PIDFILE $DAEMON
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $LOCKFILE $PIDFILE
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: oacapi {start|stop|status|restart}"
exit 1
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment