mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
New status info
This commit is contained in:
parent
7bec3ff5dd
commit
45b3c68930
@ -30,10 +30,20 @@ def health_status(request):
|
||||
|
||||
request._inventree_health_status = True
|
||||
|
||||
return {
|
||||
"system_healthy": InvenTree.status.check_system_health(),
|
||||
status = {
|
||||
'django_q_running': InvenTree.status.is_q_cluster_running(),
|
||||
}
|
||||
|
||||
all_healthy = True
|
||||
|
||||
for k in status.keys():
|
||||
if status[k] is not True:
|
||||
all_healthy = False
|
||||
|
||||
status['system_healthy'] = all_healthy
|
||||
|
||||
return status
|
||||
|
||||
|
||||
def status_codes(request):
|
||||
"""
|
||||
|
@ -1,15 +1,32 @@
|
||||
"""
|
||||
Provides system status functionality checks.
|
||||
"""
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django_q.monitor import Stat
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_q_cluster_running(**kwargs):
|
||||
"""
|
||||
Return True if at least one cluster worker is running
|
||||
"""
|
||||
|
||||
clusters = Stat.get_all()
|
||||
|
||||
for cluster in clusters:
|
||||
print("Cluster:", cluster)
|
||||
|
||||
return len(clusters) > 0
|
||||
|
||||
|
||||
def check_system_health(**kwargs):
|
||||
"""
|
||||
Check that the InvenTree system is running OK.
|
||||
@ -19,7 +36,7 @@ def check_system_health(**kwargs):
|
||||
|
||||
result = True
|
||||
|
||||
if not check_celery_worker(**kwargs):
|
||||
if not is_q_cluster_running(**kwargs):
|
||||
result = False
|
||||
logger.warning(_("Celery worker check failed"))
|
||||
|
||||
@ -27,13 +44,3 @@ def check_system_health(**kwargs):
|
||||
logger.warning(_("InvenTree system health checks failed"))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def check_celery_worker(**kwargs):
|
||||
"""
|
||||
Check that a celery worker is running.
|
||||
"""
|
||||
|
||||
# TODO - Checks that the configured celery worker thing is running
|
||||
|
||||
return True
|
||||
|
@ -13,8 +13,9 @@
|
||||
<td>{% trans "Instance Name" %}</td>
|
||||
<td>{% inventree_instance_name %}</td>
|
||||
</tr>
|
||||
{% if user.is_staff %}
|
||||
<tr>
|
||||
<td><span class='fas fa-exclamation-triangle'></span></td>
|
||||
<td><span class='fas fa-server'></span></td>
|
||||
<td>{% trans "Server status" %}</td>
|
||||
<td>
|
||||
{% if system_healthy %}
|
||||
@ -24,6 +25,18 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class='fas fa-tasks'></span></td>
|
||||
<td>{% trans "Background Worker" %}</td>
|
||||
<td>
|
||||
{% if django_q_running %}
|
||||
<span class='label label-green'>{% trans "Operational" %}</span>
|
||||
{% else %}
|
||||
<span class='label label-red'>{% trans "Not running" %}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{% if not system_healthy %}
|
||||
{% for issue in system_issues %}
|
||||
|
Loading…
Reference in New Issue
Block a user