Commits

theoden  committed 960c2d6

* Several instances of the Nginx are now possible for the same INSTANCE_NAME
test for Project.remove is broken

  • Participants
  • Parent commits c6ec661
  • Branches multiple web-servers

Comments (0)

Files changed (1)

File fab_deploy/webserver/nginx.py

     
     def __init__(self, config='nginx.conf'):
         self.config = config
-        
+
+    def _get_server_config_name(self):
+        return '%s_%s' % (env.conf['INSTANCE_NAME'], self.config)
+
     @task_method
     @utils.run_as_sudo
     def install(self):
         options = {'lenny': '-t lenny-backports'}
         system.aptitude_install('nginx', options.get(os, ''))
         sudo('rm -f /etc/nginx/sites-enabled/default')
-    
+
     @task_method
     @utils.run_as_sudo
     def update_config(self):
         """ Updates nginx config and restarts nginx. """
-        name = env.conf['INSTANCE_NAME']
+        name = self._get_server_config_name()
         utils.upload_config_template(self.config,
                                      '/etc/nginx/sites-available/%s' % name,
                                      use_sudo=True)
         with settings(warn_only=True):
             sudo('ln -s /etc/nginx/sites-available/%s /etc/nginx/sites-enabled/%s' % (name, name))
         sudo('invoke-rc.d nginx restart')
+
+    @task_method
+    @utils.run_as_sudo
+    def disable_config(self):
+        """ Disables nginx config and reloads nginx. """
+        sudo('rm -f /etc/nginx/sites-enabled/' + self._get_server_config_name())
+        sudo('invoke-rc.d nginx reload')