mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix -1 showing on dashboard when offline
This commit is contained in:
parent
5bb17eae33
commit
478dfdc6ef
@ -130,16 +130,19 @@ class Stats:
|
|||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _try_get_process_stats(process):
|
def _try_get_process_stats(process, running):
|
||||||
try:
|
if running:
|
||||||
return Stats._get_process_stats(process)
|
try:
|
||||||
except Exception as e:
|
return Stats._get_process_stats(process)
|
||||||
logger.debug(
|
except Exception as e:
|
||||||
f"getting process stats for pid {process.pid} "
|
logger.debug(
|
||||||
"failed due to the following error:",
|
f"getting process stats for pid {process.pid} "
|
||||||
exc_info=e,
|
"failed due to the following error:",
|
||||||
)
|
exc_info=e,
|
||||||
return {"cpu_usage": -1, "memory_usage": -1, "mem_percentage": -1}
|
)
|
||||||
|
return {"cpu_usage": -1, "memory_usage": -1, "mem_percentage": -1}
|
||||||
|
else:
|
||||||
|
return {"cpu_usage": 0, "memory_usage": 0, "mem_percentage": 0}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_process_stats(process):
|
def _get_process_stats(process):
|
||||||
|
@ -1250,7 +1250,7 @@ class ServerInstance:
|
|||||||
server_path = server["path"]
|
server_path = server["path"]
|
||||||
|
|
||||||
# process stats
|
# process stats
|
||||||
p_stats = Stats._try_get_process_stats(self.process)
|
p_stats = Stats._try_get_process_stats(self.process, self.check_running())
|
||||||
|
|
||||||
# TODO: search server properties file for possible override of 127.0.0.1
|
# TODO: search server properties file for possible override of 127.0.0.1
|
||||||
internal_ip = server["server_ip"]
|
internal_ip = server["server_ip"]
|
||||||
@ -1383,7 +1383,7 @@ class ServerInstance:
|
|||||||
server_path = server_dt["path"]
|
server_path = server_dt["path"]
|
||||||
|
|
||||||
# process stats
|
# process stats
|
||||||
p_stats = Stats._try_get_process_stats(self.process)
|
p_stats = Stats._try_get_process_stats(self.process, self.check_running())
|
||||||
|
|
||||||
# TODO: search server properties file for possible override of 127.0.0.1
|
# TODO: search server properties file for possible override of 127.0.0.1
|
||||||
# internal_ip = server['server_ip']
|
# internal_ip = server['server_ip']
|
||||||
|
Loading…
Reference in New Issue
Block a user