mirror of https://github.com/Aidaho12/haproxy-wi
parent
a0edb5975f
commit
55815f5710
18
app/funct.py
18
app/funct.py
|
@ -1670,6 +1670,7 @@ def get_service_version(server_ip, service_name):
|
|||
def get_services_status():
|
||||
import distro
|
||||
services = []
|
||||
is_in_docker = is_docker()
|
||||
services_name = {'roxy-wi-checker': 'Checker backends master service',
|
||||
'roxy-wi-keep_alive': 'Auto start service',
|
||||
'roxy-wi-metrics': 'Metrics master service',
|
||||
|
@ -1681,7 +1682,10 @@ def get_services_status():
|
|||
'fail2ban': 'Fail2ban service',
|
||||
'rabbitmq-server': 'Message broker service'}
|
||||
for s, v in services_name.items():
|
||||
cmd = "systemctl is-active %s" % s
|
||||
if is_in_docker:
|
||||
cmd = "sudo supervisorctl status " + s + "|awk '{print $2}'"
|
||||
else:
|
||||
cmd = "systemctl is-active %s" % s
|
||||
status, stderr = subprocess_execute(cmd)
|
||||
if s != 'roxy-wi-keep_alive':
|
||||
service_name = s.split('_')[0]
|
||||
|
@ -2007,3 +2011,15 @@ def get_correct_apache_service_name(server_ip=0, server_id=0):
|
|||
return 'httpd'
|
||||
else:
|
||||
return 'apache2'
|
||||
|
||||
|
||||
def is_docker():
|
||||
import os, re
|
||||
|
||||
path = "/proc/self/cgroup"
|
||||
if not os.path.isfile(path): return False
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
if re.match("\d+:[\w=]+:/docker(-[ce]e)?/\w+", line):
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -487,7 +487,7 @@ if form.getvalue('action_apache') is not None and serv is not None:
|
|||
|
||||
if form.getvalue('action_service') is not None:
|
||||
action = form.getvalue('action_service')
|
||||
is_in_docker = os.environ.get('IN_DOCKER', False)
|
||||
is_in_docker = funct.is_docker()
|
||||
if action == 'stop':
|
||||
cmd = "sudo systemctl disable %s --now" % serv
|
||||
elif action == "start":
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{% for s in services %}
|
||||
<tr class="{{ loop.cycle('odd', 'even') }}" id="{{s.0}}">
|
||||
<td class="padding10 first-collumn">
|
||||
{% if s.1.0 == 'active' %}
|
||||
{% if s.1.0 == 'active' or s.1.0 == 'RUNNING' %}
|
||||
<span title="{{s.0}} is started"><span class="serverUp server-status"></span></span>
|
||||
{% else %}
|
||||
{% if (s.1.0 == 'inactive' or s.1.0 == 'failed' or s.1.0 == 'activating') and 'is not installed' not in s.3 %}
|
||||
{% if (s.1.0 == 'inactive' or s.1.0 == 'failed' or s.1.0 == 'activating' or s.1.0 == 'STOPPED') and 'is not installed' not in s.3 %}
|
||||
<span title="{{s.0}} is stopped"><span class="serverDown server-status"></span></span>
|
||||
{% else %}
|
||||
<span title="{{s.0}} is not installed"><span class="serverNone server-status"></span></span>
|
||||
|
|
Loading…
Reference in New Issue