Don't restart apps on update-host
This commit is contained in:
parent
340323a0b5
commit
0605110050
@ -214,10 +214,6 @@ class VMMgr:
|
|||||||
self.domain = self.conf['host']['domain'] = domain
|
self.domain = self.conf['host']['domain'] = domain
|
||||||
self.port = self.conf['host']['port'] = port
|
self.port = self.conf['host']['port'] = port
|
||||||
self.conf.save()
|
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.
|
# Rebuild and restart nginx if it was requested.
|
||||||
self.rebuild_nginx()
|
self.rebuild_nginx()
|
||||||
|
|
||||||
|
@ -86,14 +86,11 @@ def start_service(service):
|
|||||||
def stop_service(service):
|
def stop_service(service):
|
||||||
subprocess.run(['/sbin/service', service, 'stop'], check=True)
|
subprocess.run(['/sbin/service', service, 'stop'], check=True)
|
||||||
|
|
||||||
def restart_service(service):
|
|
||||||
subprocess.run(['/sbin/service', service, 'restart'])
|
|
||||||
|
|
||||||
def reload_nginx():
|
def reload_nginx():
|
||||||
subprocess.run(['/usr/sbin/nginx', '-s', 'reload'])
|
subprocess.run(['/usr/sbin/nginx', '-s', 'reload'])
|
||||||
|
|
||||||
def restart_nginx():
|
def restart_nginx():
|
||||||
restart_service('nginx')
|
restart_service(['/sbin/service', 'nginx', 'restart'])
|
||||||
|
|
||||||
def get_cert_info(cert):
|
def get_cert_info(cert):
|
||||||
# Gather certificate data important for setup-host
|
# Gather certificate data important for setup-host
|
||||||
|
@ -90,6 +90,7 @@ class WSGIApp(object):
|
|||||||
response.status_code = 404
|
response.status_code = 404
|
||||||
return response
|
return response
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
|
# Return MethodNotAllowed or RequestRedirect as they are
|
||||||
return e
|
return e
|
||||||
|
|
||||||
def render_template(self, template_name, request, **context):
|
def render_template(self, template_name, request, **context):
|
||||||
@ -118,7 +119,7 @@ class WSGIApp(object):
|
|||||||
return message.split(':', 3)
|
return message.split(':', 3)
|
||||||
|
|
||||||
def login_view(self, request, **kwargs):
|
def login_view(self, request, **kwargs):
|
||||||
redir = request.args.get('redir')
|
redir = request.args.get('redir', '')
|
||||||
message = self.get_session_message(request)
|
message = self.get_session_message(request)
|
||||||
return self.render_html('login.html', request, redir=redir, message=message)
|
return self.render_html('login.html', request, redir=redir, message=message)
|
||||||
|
|
||||||
@ -231,8 +232,10 @@ class WSGIApp(object):
|
|||||||
domain = request.form['domain']
|
domain = request.form['domain']
|
||||||
port = request.form['port']
|
port = request.form['port']
|
||||||
self.vmmgr.update_host(domain, port)
|
self.vmmgr.update_host(domain, port)
|
||||||
server_name = request.environ['HTTP_X_FORWARDED_SERVER_NAME']
|
ip = tools.get_local_ip(4)
|
||||||
url = '{}/setup-host'.format(tools.compile_url(server_name, port))
|
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 = self.render_json({'ok': request.session.lang.host_updated(url, url)})
|
||||||
response.call_on_close(tools.restart_nginx)
|
response.call_on_close(tools.restart_nginx)
|
||||||
return response
|
return response
|
||||||
@ -411,6 +414,3 @@ class WSGIApp(object):
|
|||||||
|
|
||||||
def is_app_visible(self, app):
|
def is_app_visible(self, app):
|
||||||
return app in self.conf['apps'] and self.conf['apps'][app]['visible'] and tools.is_service_started(app)
|
return app in self.conf['apps'] and self.conf['apps'][app]['visible'] and tools.is_service_started(app)
|
||||||
|
|
||||||
class InvalidRecordException(Exception):
|
|
||||||
pass
|
|
||||||
|
@ -27,9 +27,7 @@ $(function() {
|
|||||||
function update_host() {
|
function update_host() {
|
||||||
$('#host-submit').hide();
|
$('#host-submit').hide();
|
||||||
$('#host-message').hide();
|
$('#host-message').hide();
|
||||||
$('#host-wait').show();
|
|
||||||
$.post('/update-host', {'domain': $('#domain').val(), 'port': $('#port').val()}, function(data) {
|
$.post('/update-host', {'domain': $('#domain').val(), 'port': $('#port').val()}, function(data) {
|
||||||
$('#host-wait').hide();
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
$('#host-message').attr('class','error').html(data.error).show();
|
$('#host-message').attr('class','error').html(data.error).show();
|
||||||
$('#host-submit').show();
|
$('#host-submit').show();
|
||||||
|
@ -21,10 +21,6 @@
|
|||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<input type="submit" id="host-submit" value="Nastavit hostitele">
|
<input type="submit" id="host-submit" value="Nastavit hostitele">
|
||||||
<div id="host-message"></div>
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user