Skip to content

Instantly share code, notes, and snippets.

@guillochon
Last active Apr 22, 2018
Embed
What would you like to do?
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