Merge rebuild_nginx into update_host

This commit is contained in:
Disassembler 2019-06-04 08:42:41 +02:00
parent d6f738c47e
commit ebd24befaf
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -55,14 +55,10 @@ class VMMgr:
self.reload_nginx()
def update_host(self, domain, port):
# Update domain and port and rebuild all configuration. Web interface calls restart_nginx() in WSGI close handler
# Update domain and port, rebuild all configuration and restart nginx
self.domain = self.conf['host']['domain'] = domain
self.port = self.conf['host']['port'] = port
self.conf.save()
# Rebuild and restart nginx if it was requested.
self.rebuild_nginx()
def rebuild_nginx(self):
# Rebuild nginx config for the portal app. Web interface calls restart_nginx() in WSGI close handler
with open(os.path.join(NGINX_DIR, 'default.conf'), 'w') as f:
f.write(templates.NGINX_DEFAULT.format(port=self.port, domain_esc=self.domain.replace('.', '\\.')))