Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proxy): Remove conflicting site before adding a new site #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions agent/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ def add_wildcard_hosts(self, wildcards):

@job("Add Site to Upstream")
def add_site_to_upstream_job(self, upstream, site, skip_reload=False):
self.remove_conflicting_site(site)
self.add_site_to_upstream(upstream, site)
self.generate_proxy_config()
if skip_reload:
return
self.reload_nginx()

@step("Remove Conflicting Site")
def remove_conflicting_site(self, site):
# Go through all upstreams and remove the site file matching the site name
for upstream in self.upstreams:
conflict = os.path.join(self.upstreams_directory, upstream, site)
if os.path.exists(conflict):
os.remove(conflict)

@step("Add Site File to Upstream Directory")
def add_site_to_upstream(self, upstream, site):
upstream_directory = os.path.join(self.upstreams_directory, upstream)
Expand Down Expand Up @@ -147,6 +156,7 @@ def rename_site_on_upstream_job(
new_name: str,
skip_reload=False,
):
self.remove_conflicting_site(new_name)
self.rename_site_on_upstream(upstream, site, new_name)
site_host_dir = os.path.join(self.hosts_directory, site)
if os.path.exists(site_host_dir):
Expand Down