1. Yann Malet
  2. uwsgi emperor template configuration

Commits

Yann Malet  committed c7154e0

Move the upstart script for the etc folder. Add a basic nginx configuration

  • Participants
  • Parent commits 9554e86
  • Branches default

Comments (0)

Files changed (5)

File etc/nginx.conf

View file
+server {
+	listen   8080;
+	server_name site1.local site2.local;
+	access_log /opt/webapps/emperor-test/nginx_access_log;
+	location / {
+                root    /var/www/;
+		uwsgi_pass 127.0.0.1:3031;
+		include        uwsgi_params;
+	}
+}

File etc/uwsgi.conf

View file
+# UWSGI emperor Service
+description     "UWSGI Emperor Server"
+author          "Yann Malet <yann.malet@gmail.com>"
+
+start on runlevel [2345]
+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
+
+respawn
+
+pre-start script
+    #Sanity checks
+    if [ ! -d $UWSGI_SOCKETS ]; then
+        mkdir -p $UWSGI_SOCKETS
+        chown -R $UWSGI_USER.$UWSGI_GROUP $UWSGI_SOCKETS
+    fi
+end script
+
+script
+    chdir $EMPEROR_HOME
+    . ve/bin/activate
+    exec uwsgi --emperor "vassal-sites/*/*.xml"  --logto $EMPEROR_HOME/uwsgi.log --pidfile $EMPEROR_HOME/uwsgi.pid --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

File uwsgi.conf

-# UWSGI emperor Service
-description     "UWSGI Emperor Server"
-author          "Yann Malet <yann.malet@gmail.com>"
-
-start on runlevel [2345]
-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
-
-respawn
-
-pre-start script
-    #Sanity checks
-    if [ ! -d $UWSGI_SOCKETS ]; then
-        mkdir -p $UWSGI_SOCKETS
-        chown -R $UWSGI_USER.$UWSGI_GROUP $UWSGI_SOCKETS
-    fi
-end script
-
-script
-    chdir $EMPEROR_HOME
-    . ve/bin/activate
-    exec uwsgi --emperor "vassal-sites/*/*.xml"  --logto $EMPEROR_HOME/uwsgi.log --pidfile $EMPEROR_HOME/uwsgi.pid --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

File vassal-sites/site1/site1.py

View file
 import uwsgi
 
+# Cherokee listen to the port 80
 # delete old value from remote cache
 uwsgi.cache_del('site1.local', '127.0.0.1:3032')
 # add the new mapping to the fastrouter remote cache
 uwsgi.cache_set('site1.local', uwsgi.opt['socket'], 0, '127.0.0.1:3032')
 
+# nginx listen to the port 8080
+# delete old value from remote cache
+uwsgi.cache_del('site1.local:8080', '127.0.0.1:3032')
+# add the new mapping to the fastrouter remote cache
+uwsgi.cache_set('site1.local:8080', uwsgi.opt['socket'], 0, '127.0.0.1:3032')
+
 
 def application(environ, start_response):
     start_response('200 OK', [('Content-Type', 'text/plain')])
     yield 'Hello World from site 1\n'
+
+uwsgi.applications = {'': application }

File vassal-sites/site2/site2.py

View file
 import uwsgi
 
+# Cherokee listen to the port 80
 # delete old value from remote cache
 uwsgi.cache_del('site2.local', '127.0.0.1:3032')
 # add the new mapping to the fastrouter remote cache
 uwsgi.cache_set('site2.local', uwsgi.opt['socket'], 0, '127.0.0.1:3032')
 
+# nginx listen to the port 8080
+# delete old value from remote cache
+uwsgi.cache_del('site2.local:8080', '127.0.0.1:3032')
+# add the new mapping to the fastrouter remote cache
+uwsgi.cache_set('site2.local:8080', uwsgi.opt['socket'], 0, '127.0.0.1:3032')
+
+
 def application(environ, start_response):
     start_response('200 OK', [('Content-Type', 'text/plain')])
     yield 'Hello World from site 2\n'
+
+uwsgi.applications = {'': application }