diff --git a/doc/integration/web_servers.rst b/doc/integration/web_servers.rst index 2c2d11185..eef79b526 100644 --- a/doc/integration/web_servers.rst +++ b/doc/integration/web_servers.rst @@ -107,19 +107,21 @@ Nginx possible that **your** installation of uwsgi or nginx or Apache or what-have-you works differently. Keep this in mind. +This section covers two different ways of running Modoboa behind +`Nginx `_ using a WSGI application server. Choose +the one you prefer between `Green Unicorn `_ or +`uWSGI `_. + +In both cases, you'll need to download and `install nginx +`_. + Green Unicorn ============= -`Nginx `_ is a really fast HTTP server. Associated -with `Green Unicorn `_, it gives you one of the -best setups to serve python/Django applications. Modoboa's -performance is really good with this configuration. - -To use this setup, first download and install `nginx -`__ and `gunicorn +Firstly, `Download and install gunicorn `_. Then, use the following sample -gunicorn configuration (create a new file named :file:`gunicorn.conf.py` -inside Modoboa's root dir):: +gunicorn configuration (create a new file named +:file:`gunicorn.conf.py` inside Modoboa's root dir):: backlog = 2048 bind = "unix:/var/run/gunicorn/modoboa.sock" @@ -191,7 +193,7 @@ Paste this content to your configuration (replace values between ``<>`` with yours), restart nginx and enjoy a really fast application! -uwsgi +uWSGI ===== The following setup is meant to get you started quickly. You should @@ -213,8 +215,7 @@ uwsgi: Use uwsgi 1.2.6 or newer. If you do not, you *will* run into problems. Modoboa will fail in obscure ways. -To use this setup, first download and install `nginx -`__ and `uwsgi +To use this setup, first `download and install uwsgi `_. Here is a sample nginx configuration:: @@ -256,11 +257,14 @@ Here is a sample nginx configuration:: location / { include uwsgi_params; uwsgi_pass ; - uwsgi_param UWSGI_SCRIPT modoboa_server.wsgi:application + uwsgi_param UWSGI_SCRIPT .wsgi:application uwsgi_param UWSGI_SCHEME https; } } +```` must be replaced by the value you used +when :ref:`you deployed your instance `. + If you do not plan to use SSL then change the listen directive to ``listen 80;`` and delete each of the following directives:: @@ -272,7 +276,7 @@ If you do not plan to use SSL then change the listen directive to If you do plan to use SSL, you'll have to generate a certificate and a key. `This article -`__ +`_ contains information about how to do it. Make sure to replace the ``<...>`` in the sample configuration with diff --git a/modoboa/core/management/commands/cleanlogs.py b/modoboa/core/management/commands/cleanlogs.py index 0cf1c8aac..59f3859d9 100644 --- a/modoboa/core/management/commands/cleanlogs.py +++ b/modoboa/core/management/commands/cleanlogs.py @@ -2,6 +2,7 @@ # coding: utf-8 import datetime from optparse import make_option +from django import db from django.core.management.base import BaseCommand from django.utils import timezone from modoboa.core import load_core_settings @@ -42,4 +43,5 @@ class Command(BaseCommand): self.__vprint("Deleting logs older than %d days..." % log_maximum_age) limit = timezone.now() - datetime.timedelta(log_maximum_age) Log.objects.filter(date_created__lt=limit).delete() + db.close_connection() self.__vprint("Done.") diff --git a/modoboa/extensions/admin/management/commands/handle_mailbox_operations.py b/modoboa/extensions/admin/management/commands/handle_mailbox_operations.py index 056b4a55e..e282fb1c6 100644 --- a/modoboa/extensions/admin/management/commands/handle_mailbox_operations.py +++ b/modoboa/extensions/admin/management/commands/handle_mailbox_operations.py @@ -1,6 +1,7 @@ import os import logging from optparse import make_option +from django import db from django.core.management.base import BaseCommand from modoboa.lib import parameters from modoboa.lib.sysutils import exec_cmd @@ -90,3 +91,4 @@ class Command(BaseCommand): self.logger.info('%s succeed', ope) ope.delete() os.unlink(options['pidfile']) + db.close_connection() diff --git a/modoboa/extensions/amavis/management/commands/amnotify.py b/modoboa/extensions/amavis/management/commands/amnotify.py index 1ede77c6e..54846b12e 100644 --- a/modoboa/extensions/amavis/management/commands/amnotify.py +++ b/modoboa/extensions/amavis/management/commands/amnotify.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # coding: utf-8 from optparse import make_option +from django import db from django.core.management.base import BaseCommand, CommandError from django.template.loader import render_to_string from django.core.urlresolvers import reverse @@ -90,3 +91,4 @@ class Command(BaseCommand): continue rcpt = su.mailbox_set.all()[0].full_address self.send_pr_notification(rcpt, reqs) + db.close_connection() diff --git a/modoboa/extensions/amavis/management/commands/qcleanup.py b/modoboa/extensions/amavis/management/commands/qcleanup.py index c31d348f5..a1be4a32d 100644 --- a/modoboa/extensions/amavis/management/commands/qcleanup.py +++ b/modoboa/extensions/amavis/management/commands/qcleanup.py @@ -3,6 +3,7 @@ import time from optparse import make_option +from django import db from django.core.management.base import BaseCommand from modoboa.lib import parameters from modoboa.extensions.amavis import Amavis @@ -63,5 +64,6 @@ class Command(BaseCommand): for maddr in Maddr.objects.all(): if not maddr.msgs_set.count() and not maddr.msgrcpt_set.count(): maddr.delete() + db.close_connection() self.__vprint("Done.") diff --git a/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py b/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py index 3118f6cc9..f91645a4e 100644 --- a/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py +++ b/modoboa/extensions/postfix_autoreply/management/commands/autoreply.py @@ -2,6 +2,7 @@ # coding: utf-8 import sys import datetime +from django import db from django.core.management.base import BaseCommand, CommandError from django.utils import timezone from modoboa.lib import parameters @@ -64,3 +65,4 @@ class Command(BaseCommand): continue send_autoreply(sender, mbox, armessage) + db.close_connection() diff --git a/modoboa/extensions/stats/management/commands/logparser.py b/modoboa/extensions/stats/management/commands/logparser.py index e0935164b..04c182063 100644 --- a/modoboa/extensions/stats/management/commands/logparser.py +++ b/modoboa/extensions/stats/management/commands/logparser.py @@ -23,8 +23,9 @@ import os import re import rrdtool import string -from django.core.management.base import BaseCommand from optparse import make_option +from django import db +from django.core.management.base import BaseCommand from modoboa.lib import parameters from modoboa.extensions.admin.models import Domain from modoboa.extensions.stats import Stats @@ -353,3 +354,4 @@ class Command(BaseCommand): options["logfile"] = parameters.get_admin("LOGFILE", app="stats") p = LogParser(options, parameters.get_admin("RRD_ROOTDIR", app="stats")) p.process() + db.close_connection() diff --git a/requirements.txt b/requirements.txt index f7521f053..9c7b48790 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ django>=1.5,<1.6 -django-reversion>=1.8.0 +django-reversion==1.8.0 dj-database-url south lxml