Example #1
0
    def _nginx_switch(self, spec, old_build_name, new_build_name, new_port):
        # write Nginx config for the new build.
        nginx.write_server_config(
            name=new_build_name,
            server_names=spec.get('server_names', env.host_string),
            proxy_pass='******'.format(self._gunicorn_bind(new_port)),
            static_locations=self._get_nginx_static(spec, new_build_name),
            log_root=self._log_root(new_build_name),
            listen=spec.get('listen', 80))

        # delete Nginx config for the old build if it exists.
        if old_build_name:
            nginx.delete_server_config(old_build_name)

        # reload configuration.
        nginx.reload_config()
Example #2
0
    def deactivate(self):
        info = BuildInfo().load()
        if not info.active:
            return

        start_msg('Deactivating instance in role: "{0}":'.format(self._role.name))
        try:
            nginx.delete_server_config(info.active)
            nginx.reload_config()
        except:
            failed_msg('Error stopping Nginx; ignoring.')
            pass

        try:
            supervisord.stop_and_remove(info.active)
        except:
            failed_msg('Error stopping supervisor; ignoring.')
            pass
        succeed_msg('Finished deactivating instance in role: "{0}".'.format(self._role.name))