Browse Source

Use dj_static and gunicorn to run the application

Baptiste Jonglez 9 years ago
parent
commit
c84829ca8f
3 changed files with 27 additions and 7 deletions
  1. 21 6
      INSTALL.md
  2. 3 1
      celutz/wsgi.py
  3. 3 0
      requirements.txt

+ 21 - 6
INSTALL.md

@@ -56,15 +56,30 @@ Lastly, you should collect static files to serve them:
 
     python manage.py collectstatic
 
+Development
+-----------
+
+Just run the builtin Django server:
+
+    ./manage.py runserver
+
+Alternatively, you can use gunicorn exactly like in production.
+
+You also need to launch a celery worker (see below).
+
 Production
 ----------
 
-One specific information for production usage: you **really** want to serve
-the `media/` directory with a real webserver, and **not** with Django itself.
-Hundreds of tiles (small image files) will be served from this directory each
-time a client visualises a panorama.
+To run the WSGI server, for instance gunicorn:
+
+    gunicorn celutz.wsgi:application
+
+Internally, `dj_static` is used to serve static and media files (including tiles).
+
+As an alternative, you may wish to serve media files (everything in `media/`)
+with your web server directly.
 
-You probably also want to configure your webserver to allow to send very large
+You probably also need to configure your webserver to allow to send very large
 files in a POST request.  An upper limit of 200 MB should be enough, even for
 very large pictures in raw format.
 
@@ -73,7 +88,7 @@ Tile generation
 
 Tile generation uses Celery, because it is quite a heavy task CPU-wise.
 
-To launch a celery worker while developping, run this in your virtualenv:
+To launch a celery worker, run this in your virtualenv:
 
     celery -c 1 -A celutz.celery worker --loglevel=info
 

+ 3 - 1
celutz/wsgi.py

@@ -11,4 +11,6 @@ import os
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "celutz.settings")
 
 from django.core.wsgi import get_wsgi_application
-application = get_wsgi_application()
+from dj_static import Cling, MediaCling
+
+application = Cling(MediaCling(get_wsgi_application()))

+ 3 - 0
requirements.txt

@@ -2,9 +2,12 @@ amqp==1.4.7
 anyjson==0.3.3
 billiard==3.3.0.20
 celery==3.1.18
+dj-static==0.0.6
 Django==1.8.5
 djangorestframework==3.2.4
+gunicorn==19.3.0
 kombu==3.0.30
 Pillow==2.9.0
 pytz==2015.6
+static3==0.6.1
 wheel==0.24.0