diff --git a/debian/ai-sso-server.init b/debian/ai-sso-server.init index 442324dae11c3eebb0d64f1d23b5997611a0ef94..1cc6e9831f7312830f0f62e3789c23d83817687d 100755 --- a/debian/ai-sso-server.init +++ b/debian/ai-sso-server.init @@ -6,14 +6,18 @@ # Required-Stop: $local_fs $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: start and stop the A/I Single-Sign-On server +# Short-Description: A/I Single-Sign-On Server +# Description: Starts and stops the A/I Single-Sign-On server. ### END INIT INFO -DAEMON=/usr/sbin/sso_server +NAME=sso_server +GUNICORN=/usr/bin/gunicorn +GUNICORN_APP="sso_server.wsgi:app" +GUNICORN_OPTS= RUNDIR=/var/run/sso LOGDIR=/var/log/sso -PIDFILE=${RUNDIR}/sso_server.pid +PIDFILE=${RUNDIR}/${NAME}.pid SSO_PORT=5002 USER=ai-sso NO_START=1 @@ -25,29 +29,50 @@ check_dirs() { chown -R ${USER} ${LOGDIR} } +test -x ${GUNICORN} || exit 0 +test ${NO_START} -eq 1 && exit 0 + test -e /etc/default/ai-sso-server && . /etc/default/ai-sso-server -test -x ${DAEMON} || exit 0 -test ${NO_START} -eq 1 && exit 0 +. /lib/lsb/init-functions + +GUNICORN_OPTS=" +--bind 127.0.0.1:${SSO_PORT} +--worker-class gevent +--daemon --pid ${PIDFILE} +--name ${NAME} +${GUNICORN_OPTS} +" case "$1" in start) - echo -n "Starting SSO Server... " + log_daemon_msg "Starting SSO server" check_dirs - start-stop-daemon --start --pidfile ${PIDFILE} --make-pidfile \ - --background --chuid ${USER} --exec ${DAEMON} -- --port=${SSO_PORT} - echo "ok" + start-stop-daemon --start --oknodo \ + --pidfile ${PIDFILE} \ + --chuid ${USER} \ + --exec ${GUNICORN} -- ${GUNICORN_OPTS} ${GUNICORN_APP} + if [ $? -eq 0 ]; then + log_success_msg + else + log_failure_msg + exit 1 + fi ;; stop) - echo -n "Stopping SSO Server... " - start-stop-daemon --stop \ - --pidfile ${PIDFILE} && rm -f ${PIDFILE} - echo "ok" + log_daemon_msg "Stopping SSO server" + start-stop-daemon --stop --oknodo --user ${USER} --pidfile ${PIDFILE} + if [ $? -eq 0 ]; then + log_success_msg + else + log_failure_msg + fi + rm -f ${PIDFILE} 2>/dev/null ;; reload) - echo -n "Reloading SSO Server... " + log_daemon_msg "Reloading SSO server" kill -HUP `cat ${PIDFILE}` - echo "ok" + log_success_msg ;; restart) $0 stop @@ -55,7 +80,8 @@ restart) $0 start ;; *) - echo -e "Only [start|stop|reload|restart] operation are allowed\n" + echo "Usage: /etc/init.d/ai-sso-server {start|stop|reload|restart}" 1>&2 + exit 1 ;; esac diff --git a/debian/changelog b/debian/changelog index 44242a2f0622b740cd9ee0be730cafe0918ac179..b39dab2fa6b33e6be2f93c22bf66d409ca9d0765 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ai-sso (2.0.1) unstable; urgency=low + + * OTP support. + * Use 'gunicorn' for serving. + + -- Autistici/Inventati <debian@autistici.org> Sun, 30 Mar 2014 11:35:20 +0100 + ai-sso (2.0) unstable; urgency=low * Source upgraded to version 2.0. diff --git a/debian/control b/debian/control index 2340ab0c2156fb4dab002c855ae17fe2790b39f9..0791faeebb0798aafd2ba27582ea982202089221 100644 --- a/debian/control +++ b/debian/control @@ -21,7 +21,8 @@ Description: A/I SSO Python modules. Package: ai-sso-server Architecture: all -Depends: ai-sso, ai-sso-python, python-flask, ${python:Depends} +Depends: ai-sso, ai-sso-python, python-flask, gunicorn, + python-setproctitle, lsb-base, adduser, ${python:Depends} Description: A/I SSO Server. The login server for the A/I SSO service.