Commits

Yann Malet committed a50111f

Add an upstart script that could start uwsgi emperor instance

  • Participants
  • Parent commits b95bcab

Comments (0)

Files changed (2)

     """
     Stops the emperor, deletes the pid and the log
     """
-    stop_emperor()
+    try:
+        print "stopping this emperor"
+        stop_emperor()
+    except:
+        print "the emperor is not running"
     delete_emperor_pid()
     delete_emperor_log()
     
+# UWSGI emperor Service
+description     "UWSGI Emperor Server"
+author          "Yann Malet <yann.malet@gmail.com>"
+
+start on startup
+stop on runlevel [016]
+
+env EMPEROR_HOME=/opt/webapps/emperor-test
+env UWSGI_SOCKETS=/tmp/sockets
+env UWSGI_GROUP=www-data
+env UWSGI_USER=www-data
+
+# time to wait between sending TERM and KILL signals
+kill timeout 6
+
+# TODO: This does not work for some reason
+# The pid is not correct 
+expect daemon
+#respawn
+
+# This directive is deprecated
+#pid file $EMPEROR_HOME/uwsgi.pid
+
+pre-start script
+    #Sanity checks
+    if [ ! -d $UWSGI_SOCKETS ]; then
+        mkdir -p $UWSGI_SOCKETS
+        chown -R www-data.www-data $UWSGI_SOCKETS
+    fi
+end script
+
+script
+    chdir $EMPEROR_HOME
+    . ve/bin/activate
+    exec uwsgi --emperor "vassal-sites/*/*.xml"  --logto $EMPEROR_HOME/uwsgi.log --fastrouter :3031 --fastrouter-use-cache --cache 100 --socket :3032 --gid $UWSGI_GROUP --uid $UWSGI_USER
+end script
+
+post-stop script
+    if [ -e $EMPEROR_HOME/uwsgi.pid ]; then
+        rm $EMPEROR_HOME/uwsgi.pid 
+    fi
+end script