#!/bin/sh # # gunicorn_sr Startup script for gunicorn for sr # # chkconfig: - 86 14 # processname: gunicorn # pidfile: # description: Python application server in ubuntu # ### BEGIN INIT INFO # Provides: gunicorn_sr # Required-Start: $local_fs $remote_fs $network # Required-Stop: $local_fs $remote_fs $network # Default-Start: 3 # Default-Stop: 0 1 2 4 5 6 # Short-Description: start and stop gunicorn ### END INIT INFO # Source function library. #. /etc/rc.d/init.d/functions prog=gunicorn gunicorn_home=/home/openerp/gunicorn APP_ROOT=/home/openerp/openerp7/openobject-server UNICORN_CONF=$APP_ROOT/newtime-wsgi.py lockfile=${LOCKFILE-$gunicorn_home/var/lock/gunicorn} pidfile=$gunicorn_home/var/run/gunicorn_sr.pid pidfile_old=${pidfile}.oldbin RETVAL=0 ##gunicorn config### gunicorn_wsgi_app=openerp:service.wsgi_server.application gunicorn_bind=0.0.0.0:8069 gunicorn_workers=4 errorlog=$gunicorn_home/var/logs/gunicorn-error.log accesslog=$gunicorn_home/var/logs/gunicorn-access.log loglevel=debug timeout=50000 virtualenv_dir=OPENERP start() { echo -n $"Starting $prog: " cd $APP_ROOT . $virtualenv_dir/bin/activate gunicorn --config $UNICORN_CONF --pid $pidfile --daemon -w $gunicorn_workers --access-logfile $accesslog --log-level $loglevel -b $gunicorn_bind $gunicorn_wsgi_app RETVAL=$? echo -n [ $RETVAL = 0 ] && echo -e '[\e[32m OK \e[m]' [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping $prog: " pkill -p ${pidfile} ${prog} -QUIT RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } restart() { echo -n $"Restarting $prog: " pkill -p ${pidfile} ${prog} -USR2 RETVAL=$? echo echo -n $"Stopping old $prog: " pkill -p ${pidfile_old} ${prog} -QUIT RETVAL=$? echo } reload() { echo -n $"Reloading $prog: " pkill -p ${pidfile} ${prog} -HUP RETVAL=$? echo } rh_status() { status -p ${pidfile} ${prog} } # See how we were called. case "$1" in start) rh_status >/dev/null 2>&1 && exit 0 start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart|try-restart) if rh_status >/dev/null 2>&1; then stop start fi ;; status) rh_status RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|condrestart|try-restart|status|help}" RETVAL=2 esac exit $RETVAL