Commits

Sebastien Beal committed 2cdd7f2

introducted env.conf.WEB_SERVERS to set up different choices than apache and nginx. default are still those 2.

Comments (4)

  1. Mikhail Korobov

    Hello Sebastien,

    We have a branch ("multiple-web-servers") where this issue is resolved in an another way; the docs are still lacking but code is working; this branch will be merged in "default" very soon - I hope you will like it.

    1. Sebastien Beal author

      Yes I noticed afterward. I am currently working on the "multiple web-servers" branch too, planning to add support for flask, supervisor and gunicorn.

      BTW, I don't know if it is a bug or if you are using an other version of fabric-taskset but WebProject method _expose_to(module_obj) return a generator, not a list. I couldn't test with the VMs yet as my updated OS X broke VirtualBox badly.

      1. Mikhail Korobov

        Great, thanks!

        I forgot to merge fabric-taskset changes from https://bitbucket.org/theoden/fabric-taskset :)

        As for multiple-web-servers, there would be a couple of naming changes (I don't like "app", "apps", etc. names because it is easy to confuse them with django apps).

        The following supervisord module may be a starting point: https://bitbucket.org/kmike/django-fab-deploy/issue/50/built-in-supervisord-module

        Our current discussions about DFD was in private Russian emails; if you have something to discuss feel free to create a topic in google group ( https://groups.google.com/forum/?fromgroups#!forum/django-fab-deploy ); we'd better to move there too.

  2. Sebastien Beal author

    regarding, the "apps" name, I think it would make sense to call it "services" instead. For instance, one of my project is organised this way:

    services = dict( api=Django(Nginx(), Gunicorn()), broker=Supervisord(), ) project = WebProject(services=services).expose_as_module('myService')

Files changed (5)

 
 Major changes:
 
+- Introduced :attr:`env.conf.WEB_SERVERS` to manage other webservers than nginx
+  and apache
 - All tasks are now new-style fabric tasks;
 - postgres (+ postgis) support;
 - db backends and vcs backends are now fully reusable and extendable
    ``fab full_deploy`` command:
 
    * installs necessary system and python packages;
-   * configures apache and ngnix;
+   * configures the list :attr:`env.conf.WEB_SERVERS` ( default are apache and 
+     ngnix );
    * creates virtualenv;
    * uploads project to the server;
    * runs ``python manage.py syncdb`` and ``python manage.py migrate`` commands
 
 2. Update web server configuration::
 
-       fab setup_web_server
+       fab deploy.setup_web_server
 
 3. Update django configuration (:file:`config.server.py`)::
 
-       fab update_django_config
+       fab deploy.update_django_config
 
 4. Requirements are updated with :func:`fab_deploy.virtualenv.pip_update`
    command. Update requirements listed in reqs/active.txt::
 
-       fab pip_update
+       fab pip.update_r
 
    Update requirements listed in reqs/my_apps.txt::
 
-       fab pip_update:my_apps
+       fab pip.update_r:my_apps
 
 5. Remotely change branch or revision (assuming :attr:`env.conf.VCS`
    is not 'none')::

fab_deploy/deploy.py

 from fab_deploy import django_commands as dj_cmd
 from fab_deploy import system
 from fab_deploy import vcs
+from fab_deploy import webserver
 from fab_deploy.webserver import apache, nginx
 
 
         env.conf, True
     )
     if restart:
-        apache.touch()
+        if 'apache' in env.conf.WEB_SERVERS:
+            apache.touch()
 
 @task
 def up(branch=None, before_restart=lambda: None):
 
 @task
 def setup_web_server():
-    """ Sets up a web server (apache + nginx). """
-    apache.install()
-    nginx.install()
+    """ Sets up a web server based on the WEB_SERVERS list. """
+    for server in env.conf.WEB_SERVERS:
+        try:
+            s = getattr(webserver, server)
+        except:
+            abort("Server %s is not supported." % server)    
+        s.install()
 
-    apache.setup()
-    nginx.setup()
+    for server in env.conf.WEB_SERVERS:
+        s = getattr(webserver, server)
+        s.setup()
 
 @task
 def push(*args, **kwargs):

fab_deploy/pip.py

 from fabric.api import run, env, cd, task
 from fab_deploy import utils
 
-# FIXME: this shouldn't be apache-centered
 from fab_deploy.webserver import apache
 
 __all__ = ['pip', 'install_r', 'update_r', 'setup_conf']
     what = utils._pip_req_path(what or env.conf.PIP_REQUIREMENTS_ACTIVE)
     run('pip install %s -r %s' % (options, what))
     if restart:
-        apache.touch()
+        if 'apache' in env.conf.WEB_SERVERS:
+            apache.touch()
 
 @task
 @utils.inside_src
     what = utils._pip_req_path(what or env.conf.PIP_REQUIREMENTS_ACTIVE)
     run('pip install %s -U -r %s' % (options, what))
     if restart:
-        apache.touch()
+        if 'apache' in env.conf.WEB_SERVERS:
+            apache.touch()
 
 @task
 def setup_conf(username=None):

fab_deploy/utils.py

         THREADS=15,
         SERVER_NAME=host,
         SERVER_ADMIN='example@example.com',
+        WEB_SERVERS=['apache', 'nginx'],
         PORTS = PortManager(env.conf['INSTANCE_NAME']),
         VCS='hg',