Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial modifications for nginx/uwsgi/supervisord environment and dep…

…loyment
  • Loading branch information...
commit d8a71379daffc5d96f78108a07b295b30421d488 1 parent faddaab
Matt Wright authored
View
54 etc/nginx/nginx.conf.tmpl
@@ -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/static;
+ expires 1y;
+ add_header Cache-Control "public";
+ }
+
+ location /images {
+ alias %(app_path)s/data/giveaminute/images";
+ }
+
+ location /crossdomain.xml {
+ alias %(app_path)s/static/util/crossdomain.xml;
+ }
+
+ location /robots.txt {
+ alias %(app_path)s/static/util/robots.txt;
+ }
+
+ location /favicon.ico {
+ alias %(app_path)s/static/util/favicon.ico;
+ }
+
+ location /css {
+ alias %(app_path)s/static/css;
+ }
+
+ location /img {
+ alias %(app_path)s/static/img;
+ }
+
+ location /js {
+ alias %(app_path)s/static/js;
+ }
+
+ location /swf {
+ alias %(app_path)s/static/swf;
+ }
+
+ location /xml {
+ alias %(app_path)s/static/xml;
+ }
+}
View
16 etc/supervisor/supervisor.conf.tmpl
@@ -0,0 +1,16 @@
+[program:cbu]
+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 1
+ --chmod
+directory=%(app_path)s/current
+user=giveaminute
+autostart=true
+autorestart=true
+stopsignal=QUIT
View
2  fabfile.py
@@ -915,6 +915,8 @@ 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)
def secure_website():
"""
View
6 framework/log.py
@@ -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
6 main.py
@@ -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)
View
3  wsgi.py
@@ -0,0 +1,3 @@
+import main
+
+application = main.main().wsgifunc()

0 comments on commit d8a7137

Please sign in to comment.
Something went wrong with that request. Please try again.