theoden avatar theoden committed 0cb283b

UwsgiCustomLayoutDeployTest now works.

Comments (0)

Files changed (6)

fab_deploy/webserver/uwsgi.py

     def remove_config(self):
         """ Removes uwsgi config and reloads uwsgi. """
         name = self._get_server_config_name()
-        sudo('invoke-rc.d uwsgi stop '+name)
         sudo('rm -f /etc/uwsgi/apps-enabled/'+name)
         sudo('rm -f /etc/uwsgi/apps-available/'+name)
+        # with the emperor mode vassal should be killed 
+        # when it's config had been removed
 
     @task_method
     @utils.run_as_sudo

fab_deploy_tests/test_project/config_templates/uwsgi.ini

 master = 1
 processes = {{ PROCESSES }}
 socket = 127.0.0.1:0
-st = 127.0.0.1:1337:{{ SERVER_NAME }} 
+st = 127.0.0.1:1337:{{ SERVER_NAME }}
+unsubscribe-on-graceful-reload

fab_deploy_tests/test_project2/fabfile.py

 from fab_deploy.utils import define_host
 from fab_deploy.webserver.apache import Apache
+from fab_deploy.webserver.uwsgi import Uwsgi
 from fab_deploy.webserver.nginx import Nginx
 from fab_deploy.django import Django
 from fab_deploy.project import WebProject
 )
 project = WebProject(apps).expose_as_module('project')
 
+uwsgi_services = dict(
+    django=Django(
+        Nginx('nginx_uwsgi.config'), Uwsgi(wsgi='django_wsgi.py'),
+        local_config='local_settings.py', remote_config='staging_settings.py'
+    )
+)
+project_u = WebProject(uwsgi_services).expose_as_module('project_u')
+
 @define_host('foo2@127.0.0.1:2222', LAYOUT_OPTIONS)
 def foo_site():
     return dict(

fab_deploy_tests/test_project2/hosting/nginx_uwsgi.config

+server {
+    listen 80;
+    server_name {{ SERVER_NAME }} www.{{ SERVER_NAME }};
+    access_log /var/log/nginx/{{ SERVER_NAME }}.access.log;
+    charset utf-8;
+    client_max_body_size 8m;
+
+    gzip_types text/plain text/xml text/css application/javascript application/x-javascript application/json;
+
+    location / {
+      include uwsgi_params;
+      uwsgi_param UWSGI_FASTROUTER_KEY $host;
+      uwsgi_pass 127.0.0.1:1336;
+   } 
+
+    # change /static to your static folder name
+    location /static {
+        root {{ PROJECT_DIR }};
+        autoindex off;
+        expires 1M;
+    }
+
+    # admin media serving
+    # (this location is available if django is installed from svn)
+    location /media {
+        root {{ ENV_DIR }}/src/django/django/contrib/admin;
+        expires 10m;
+        autoindex off;
+    }
+
+    # alternative django admin media path
+#    location /static/admin {
+#        root {{ PROJECT_DIR }};
+#        autoindex off;
+#        expires 10m;
+#    }
+
+    #error_page  404  /404.html;
+
+    # redirect server error pages to the static page /50x.html
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   /var/www/nginx-default;
+    }
+}

fab_deploy_tests/test_project2/hosting/uwsgi.ini

+# django < 1.4 options
+[uwsgi]
+uid = {{ USER }}
+logto = {{ HOME_DIR }}/%n.log
+virtualenv = {{ ENV_DIR }}
+pythonpath = {{ PROJECT_DIR }}
+pythonpath = {{ CURRENT_BACKEND.get_wsgi_dir() }}
+module = {{ CURRENT_BACKEND.get_wsgi_module_name() }}
+touch-reload = {{ CURRENT_BACKEND.get_wsgi_full_file_name() }}
+master = 1
+processes = {{ PROCESSES }}
+socket = 127.0.0.1:0
+st = 127.0.0.1:1337:{{ SERVER_NAME }}
+unsubscribe-on-graceful-reload

fab_deploy_tests/tests/deploy.py

 from .base import FabDeployTest
 from ..utils import setup_ssh, setup_sudo
 from ..test_project.fabfile import foo_site, bar_site, invalid_site, project, project_u
-from ..test_project2.fabfile import foo_site as foo_site2, project as project2
+from ..test_project2.fabfile import foo_site as foo_site2, project as project2, project_u as project_u2
 from ..test_project3.fabfile import postgis_site, postgres_site, project as project3
 
 @contextlib.contextmanager
         self.assertTrue(before_restart.called)
 
 
+class UwsgiCustomLayoutDeployTest(CustomLayoutDeployTest):
+    snapshot = 'fabtest-prepared-uwsgi'
+    project = project_u2
+
+
 class Django14LayoutDeployTest(FabDeployProjectTest):
     project_dir = 'test_project3'
     project = project3
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.