Don't restart apps on update-host

This commit is contained in:
Disassembler 2018-11-05 00:03:30 +01:00
parent 340323a0b5
commit 0605110050
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
5 changed files with 7 additions and 20 deletions

View File

@ -214,10 +214,6 @@ class VMMgr:
self.domain = self.conf['host']['domain'] = domain
self.port = self.conf['host']['port'] = port
self.conf.save()
# Restart all apps to trigger configuration refresh
for app in self.conf['apps'].copy():
if tools.is_service_started(app):
tools.restart_service(app)
# Rebuild and restart nginx if it was requested.
self.rebuild_nginx()

View File

@ -86,14 +86,11 @@ def start_service(service):
def stop_service(service):
subprocess.run(['/sbin/service', service, 'stop'], check=True)
def restart_service(service):
subprocess.run(['/sbin/service', service, 'restart'])
def reload_nginx():
subprocess.run(['/usr/sbin/nginx', '-s', 'reload'])
def restart_nginx():
restart_service('nginx')
restart_service(['/sbin/service', 'nginx', 'restart'])
def get_cert_info(cert):
# Gather certificate data important for setup-host

View File

@ -90,6 +90,7 @@ class WSGIApp(object):
response.status_code = 404
return response
except HTTPException as e:
# Return MethodNotAllowed or RequestRedirect as they are
return e
def render_template(self, template_name, request, **context):
@ -118,7 +119,7 @@ class WSGIApp(object):
return message.split(':', 3)
def login_view(self, request, **kwargs):
redir = request.args.get('redir')
redir = request.args.get('redir', '')
message = self.get_session_message(request)
return self.render_html('login.html', request, redir=redir, message=message)
@ -231,8 +232,10 @@ class WSGIApp(object):
domain = request.form['domain']
port = request.form['port']
self.vmmgr.update_host(domain, port)
server_name = request.environ['HTTP_X_FORWARDED_SERVER_NAME']
url = '{}/setup-host'.format(tools.compile_url(server_name, port))
ip = tools.get_local_ip(4)
if not ip:
ip = tools.get_local_ip(6)
url = '{}/setup-host'.format(tools.compile_url(ip, port))
response = self.render_json({'ok': request.session.lang.host_updated(url, url)})
response.call_on_close(tools.restart_nginx)
return response
@ -411,6 +414,3 @@ class WSGIApp(object):
def is_app_visible(self, app):
return app in self.conf['apps'] and self.conf['apps'][app]['visible'] and tools.is_service_started(app)
class InvalidRecordException(Exception):
pass

View File

@ -27,9 +27,7 @@ $(function() {
function update_host() {
$('#host-submit').hide();
$('#host-message').hide();
$('#host-wait').show();
$.post('/update-host', {'domain': $('#domain').val(), 'port': $('#port').val()}, function(data) {
$('#host-wait').hide();
if (data.error) {
$('#host-message').attr('class','error').html(data.error).show();
$('#host-submit').show();

View File

@ -21,10 +21,6 @@
<td colspan="2">
<input type="submit" id="host-submit" value="Nastavit hostitele">
<div id="host-message"></div>
<div id="host-wait" class="loader-wrap">
<div class="loader"></div>
<span>Provádí se změna nastavení, prosím čekejte...</span>
</div>
</td>
</tr>
</table>