From 55815f571044ac4b72f6cfb2178dd750cdcf3511 Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Wed, 11 May 2022 11:39:49 +0300 Subject: [PATCH] v6.0.1.0 Changelog: https://roxy-wi.org/changelog.py#6_0_1 --- app/funct.py | 18 +++++++++++++++++- app/options.py | 2 +- app/templates/ajax/load_services.html | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/funct.py b/app/funct.py index 5cf77869..803582b2 100644 --- a/app/funct.py +++ b/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 diff --git a/app/options.py b/app/options.py index 9a619101..ff050fac 100644 --- a/app/options.py +++ b/app/options.py @@ -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": diff --git a/app/templates/ajax/load_services.html b/app/templates/ajax/load_services.html index 787a57fb..0b12b01b 100644 --- a/app/templates/ajax/load_services.html +++ b/app/templates/ajax/load_services.html @@ -1,10 +1,10 @@ {% for s in services %} - {% if s.1.0 == 'active' %} + {% if s.1.0 == 'active' or s.1.0 == 'RUNNING' %} {% 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 %} {% else %}