Permalink
Browse files

Merge branch 'feature/nginx-uwsgi-supervisord' into develop

  • Loading branch information...
2 parents faddaab + baf5db8 commit 5e5beff8dd7b7f479d0e871c45794f4de2f3e2ba Matt Wright committed Apr 4, 2012
Showing with 1,476 additions and 4 deletions.
  1. +54 −0 etc/nginx/nginx.conf.tmpl
  2. +16 −0 etc/supervisor/supervisor.conf.tmpl
  3. +4 −0 fabfile.py
  4. +5 −1 framework/log.py
  5. +3 −3 main.py
  6. +1,353 −0 scripts/daemonwatch.py
  7. +38 −0 scripts/monitor.py
  8. +3 −0 wsgi.py
@@ -0,0 +1,54 @@
+server {
+ listen %(webserver_port)s;
+ server_name %(webserver_name)s;
+
+ access_log %(app_path)s/var/log/access.log;
+ error_log %(app_path)s/var/log/error.log;
+
+ location / {
+ include uwsgi_params;
+ uwsgi_pass unix:%(app_path)s/run/uwsgi.sock;
+ }
+
+ location /static {
+ alias %(app_path)s/current/static;
+ expires 1y;
+ add_header Cache-Control "public";
+ }
+
+ location /images {
+ alias %(app_path)s/current/data/giveaminute/images";
+ }
+
+ location /crossdomain.xml {
+ alias %(app_path)s/current/static/util/crossdomain.xml;
+ }
+
+ location /robots.txt {
+ alias %(app_path)s/current/static/util/robots.txt;
+ }
+
+ location /favicon.ico {
+ alias %(app_path)s/current/static/util/favicon.ico;
+ }
+
+ location /css {
+ alias %(app_path)s/current/static/css;
+ }
+
+ location /img {
+ alias %(app_path)s/current/static/img;
+ }
+
+ location /js {
+ alias %(app_path)s/current/static/js;
+ }
+
+ location /swf {
+ alias %(app_path)s/current/static/swf;
+ }
+
+ location /xml {
+ alias %(app_path)s/current/static/xml;
+ }
+}
@@ -0,0 +1,16 @@
+[program:%(application)s]
+command=/usr/local/bin/uwsgi
+ --socket %(app_path)s/run/uwsgi.sock
+ --logto %(app_path)s/var/log/uwsgi.log
+ --pythonpath %(app_path)s/current
+ --wsgi-file %(app_path)s/current/wsgi.py
+ --callable application
+ --max-requests 1000
+ --master
+ --processes 4
+ --chmod
+directory=%(app_path)s/current
+user=giveaminute
+autostart=true
+autorestart=true
+stopsignal=QUIT
View
@@ -915,6 +915,10 @@ def _webserver_do(action=''):
sudo_as('/usr/sbin/apachectl %(action)s' % params)
elif env.os_name == 'ubuntu10':
sudo_as('/usr/sbin/apache2ctl %(action)s' % params)
+ elif env.webserver == 'nginx':
+ sudo_as('/etc/init.d/%(webserver)s %(action)s' % params, shell=False, pty=False)
+ params['application'] = env.application
+ sudo_as('supervisorctl %(action)s %(application)s' % params, shell=False, pty=False)
def secure_website():
"""
View
@@ -54,7 +54,11 @@ def __iter__(self):
formatter = logging.Formatter("%(asctime)s %(ip)s |%(levelname)s| %(message)s <%(filename)s:%(lineno)d>")
# Log identifier/file will be the same as the file being run
-name = os.path.basename(__main__.__file__).split('.')[0]
+try:
+ name = os.path.basename(__main__.__file__).split('.')[0]
+except AttributeError, e:
+ name = 'main'
+
log = logging.getLogger(name)
# Set log level to Debug (TODO: This should be pulled from config file)
View
@@ -221,13 +221,13 @@ def main():
# Load SQLAlchemy
app.add_processor(load_sqla)
- # Finally, run the web.py app!
- app.run()
+ return app
# Main logic for the CBU application. Does some basic configuration,
# then starts the web.py application.
if __name__ == "__main__":
try:
- main()
+ app = main()
+ app.run()
except Exception, e:
log.info("ERROR: %s" % e)
Oops, something went wrong.

0 comments on commit 5e5beff

Please sign in to comment.