adjust system status displays to take multiple queues into account (Issue #91)

site-osm-baustelle
Hartmut Holzgraefe 2022-08-17 10:19:44 +00:00
rodzic 218f4f5bc8
commit 414ed5ea53
5 zmienionych plików z 131 dodań i 78 usunięć

Wyświetl plik

@ -32,7 +32,7 @@ import datetime
from .models import MapRenderingJob
import www.settings
from www.maposmatic import forms
from www.maposmatic import forms, models
import logging
@ -98,6 +98,51 @@ def get_waymarked_database_last_update():
return None
def queue_states():
queues = {}
for queue_name in www.settings.QUEUE_NAMES:
status = {}
status['running'] = www.settings.is_daemon_running(queue_name)
status['size'] = models.MapRenderingJob.objects.queue_size(queue_name)
queues[queue_name] = status
return queues
def all_queues_running():
for queue_name in www.settings.QUEUE_NAMES:
if not www.settings.is_daemon_running(queue_name):
return False
return True
def queues_overall_state():
queues_total = 0
queues_running = 0
for queue_name in www.settings.QUEUE_NAMES:
queues_total = queues_total + 1
if www.settings.is_daemon_running(queue_name):
queues_running = queues_running + 1
if queues_running == 0:
return "danger"
if queues_running < queues_total:
return "warning"
return "success"
def queues_overall_symbol():
queues_total = 0
queues_running = 0
for queue_name in www.settings.QUEUE_NAMES:
queues_total = queues_total + 1
if www.settings.is_daemon_running(queue_name):
queues_running = queues_running + 1
if queues_running == 0:
return "times"
if queues_running < queues_total:
return "exclamation"
return "check"
def all(request):
# Do not add the useless overhead of parsing blog entries when generating
# the rss feed
@ -112,7 +157,7 @@ def all(request):
paypal_lang_code = "en_US"
paypal_country_code = "US"
daemon_running = www.settings.is_daemon_running()
daemon_running = all_queues_running()
gis_lastupdate = get_osm_database_last_update()
gis_lag_ok = (gis_lastupdate
@ -168,4 +213,8 @@ def all(request):
'SUBMITTER_MAIL_LIFETIME': www.settings.SUBMITTER_MAIL_LIFETIME,
'SUBMITTER_IP_LIFETIME': www.settings.SUBMITTER_IP_LIFETIME,
'queue_states': queue_states(),
'queues_overall_state': queues_overall_state(),
'queues_overall_symbol': queues_overall_symbol(),
}

Wyświetl plik

@ -11,9 +11,9 @@
data-html="true"
data-original-title="{% trans "Platform status" %}"
data-placement="bottom"
data-content='<p>{% trans "Rendering daemon: " %}<i class="pull-right fas fa-{% if daemon_running %}check{% else %}times{% endif %}"></i></p>
<p>{% trans "GIS database: " %}<i class="pull-right fas fa-{% if gis_lag_ok %}check{% else %}{% if gis_lastupdate %}warning{% else %}times{% endif %}{% endif %}"></i></p>
<p>{% trans "WayMarked database: " %}<i class="pull-right fas fa-{% if waymarked_lag_ok %}check{% else %}{% if waymarked_lastupdate %}warning{% else %}times{% endif %}{% endif %}"></i></p>'
data-content='<p class="text-{{queues_overall_state}}">{% trans "Rendering queue(s): " %}<i class="pull-right fas fa-{{queues_overall_symbol}}"></i></p>
<p class="text-{% if gis_lag_ok %}success{% else %}{% if gis_lastupdate %}warning{% else %}danger{% endif %}{% endif %}">{% trans "GIS database: " %}<i class="pull-right fas fa-{% if gis_lag_ok %}check{% else %}{% if gis_lastupdate %}hourglass-half{% else %}times{% endif %}{% endif %}"></i></p>
<p class="text-{% if waymarked_lag_ok %}success{% else %}{% if waymarked_lastupdate %}warning{% else %}danger{% endif %}{% endif %}">{% trans "WayMarked database: " %}<i class="pull-right fas fa-{% if waymarked_lag_ok %}check{% else %}{% if waymarked_lastupdate %}hourglass-half{% else %}times{% endif %}{% endif %}"></i></p>'
class="navbar-brand popovered" href="#"><i class="fas fa-{{ platform_status }}"></i> {{BRAND_NAME}}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar-collapse" aria-expanded="false" aria-label="{% trans "Toggle navigation" %}">
@ -22,63 +22,63 @@
<div id="navbar" class="navbar-collapse collapse justify-content-end">
<ul class="navbar-nav mr-auto">
<li class="nav-item {% block menu-home %}{% endblock %}"><a class="nav-link" href="{% url "main" %}"><i class="fas fa-home"></i> {% trans "Home" %}</a></li>
<li class="nav-item {% block menu-new %}{% endblock %}"><a class="nav-link" href="{% url "new" %}"><i class="fas fa-edit"></i> {% trans "Create map" %}</a></li>
<li class="nav-item {% block menu-maps %}{% endblock %}"><a class="nav-link" href="{% url "maps" %}"><i class="fas fa-list"></i> {% trans "Maps" %}</a></li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button"><i class="fas fa-comment"></i> {% trans "About" %} <b class="caret"></b></a>
<div class="dropdown-menu">
<a class="dropdown-item" href="{% url "about" %}"><i class="fas fa-comment"></i> {% trans "About Maposmatic" %}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url "documentation_user_guide" %}"><i class="fas fa-book"></i> {% trans "User Guide" %}</a>
<a class="dropdown-item" href="{% url "documentation_api" %}"><i class="fas fa-book"></i> {% trans "API Docs" %}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="https://github.com/hholzgra/maposmatic/" target="_blank"><i class="fab fa-lg fa-git-square"></i> MapOSMatic project</a>
<a class="dropdown-item" href="https://github.com/hholzgra/ocitysmap/" target="_blank"><i class="fab fa-lg fa-git-square"></i> OCitysMap project</a>
<a class="dropdown-item" href="https://github.com/hholzgra/maposmatic-vagrant/" target="_blank"><i class="fab fa-lg fa-git-square"></i> MapOSMatic Vagrant Box</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url "rss-feed" %}"><i class="fas fa-rss-square"></i> {% trans "Maps feed" %}</a>
<a class="dropdown-item" href="{% url "error-feed" %}"><i class="fas fa-rss-square"></i> {% trans "Errors feed" %}</a>
</div>
</li>
<li class="nav-item {% block menu-home %}{% endblock %}"><a class="nav-link" href="{% url "main" %}"><i class="fas fa-home"></i> {% trans "Home" %}</a></li>
<li class="nav-item {% block menu-new %}{% endblock %}"><a class="nav-link" href="{% url "new" %}"><i class="fas fa-edit"></i> {% trans "Create map" %}</a></li>
<li class="nav-item {% block menu-maps %}{% endblock %}"><a class="nav-link" href="{% url "maps" %}"><i class="fas fa-list"></i> {% trans "Maps" %}</a></li>
{% if PAYPAL_ID %}
<li class="nav-item {% block menu-donate %}{% endblock %}"><a class="nav-item" href="{% url "donate" %}"><i class="fas fa-gift"></i> {% trans "Donate" %}</a></li>
{% endif %}
<li class="nav-item dropdown">
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button"><i class="fas fa-comment"></i> {% trans "About" %} <b class="caret"></b></a>
<div class="dropdown-menu">
<a class="dropdown-item" href="{% url "about" %}"><i class="fas fa-comment"></i> {% trans "About Maposmatic" %}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url "documentation_user_guide" %}"><i class="fas fa-book"></i> {% trans "User Guide" %}</a>
<a class="dropdown-item" href="{% url "documentation_api" %}"><i class="fas fa-book"></i> {% trans "API Docs" %}</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="https://github.com/hholzgra/maposmatic/" target="_blank"><i class="fab fa-lg fa-git-square"></i> MapOSMatic project</a>
<a class="dropdown-item" href="https://github.com/hholzgra/ocitysmap/" target="_blank"><i class="fab fa-lg fa-git-square"></i> OCitysMap project</a>
<a class="dropdown-item" href="https://github.com/hholzgra/maposmatic-vagrant/" target="_blank"><i class="fab fa-lg fa-git-square"></i> MapOSMatic Vagrant Box</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url "rss-feed" %}"><i class="fas fa-rss-square"></i> {% trans "Maps feed" %}</a>
<a class="dropdown-item" href="{% url "error-feed" %}"><i class="fas fa-rss-square"></i> {% trans "Errors feed" %}</a>
</div>
</li>
{% if PAYPAL_ID %}
<li class="nav-item {% block menu-donate %}{% endblock %}"><a class="nav-item" href="{% url "donate" %}"><i class="fas fa-gift"></i> {% trans "Donate" %}</a></li>
{% endif %}
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
<span class="{{LANGUAGE_CODE|language_flag}}"> </span> {{ LANGUAGES|getitem:LANGUAGE_CODE }} <b class="caret"></b>
</a>
<div class="dropdown-menu bg-light">
<form action="/i18n/setlang/" method="post" name="langsel" class="form-inline form-horizontal">
<input name="next" type="hidden" value="{{ request.path }}" />
<input name="next" type="hidden" value="{{ request.path }}" />
<input name="language" type="hidden" value="{{ LANGUAGE_CODE }}" />
{% for language in LANGUAGES_LIST %}
<a class="dropdown-item" href="javascript:(function() { document.langsel.language.value = '{{ language.0 }}'; document.langsel.submit(); })();"><span class="{{language.0|language_flag}}"> </span> {{ language.1 }}</a>
{% endfor %}
</form>
</div>
</li>
</li>
{% if WEBLATE_BASE_URL %}
{% if LANGUAGE_CODE != "en" %}
<li class="nav-item">
<a class="nav-link" target=_blank" href="{{ WEBLATE_BASE_URL }}engage/maposmatic/?utm_source=widget">
<img src="{{ WEBLATE_BASE_URL }}widgets/maposmatic/{{ LANGUAGE_CODE }}/svg-badge.svg" alt="Translation status" />
</a>
</li>
{% if WEBLATE_BASE_URL %}
{% if LANGUAGE_CODE != "en" %}
<li class="nav-item">
<a class="nav-link" target=_blank" href="{{ WEBLATE_BASE_URL }}engage/maposmatic/?utm_source=widget">
<img src="{{ WEBLATE_BASE_URL }}widgets/maposmatic/{{ LANGUAGE_CODE }}/svg-badge.svg" alt="Translation status" />
</a>
</li>
{% endif %}
{% endif %}
{% endif %}
</ul>
<form action="{% url "maps" %}" method="get" class="form-inline">
<div class="md-form">
<i class="fas fa-search"></i>
{{ searchform.query }}
</div>
<div class="md-form">
<i class="fas fa-search"></i>
{{ searchform.query }}
</div>
</form>
</div>
</div>

Wyświetl plik

@ -5,44 +5,43 @@
<div class="alert alert-info">
<h2>{% trans "Platform status" %}</h2>
{% if queued %}
<p class="queue">
{% blocktrans with queued|pluralize as qp %}{{ queued }} job{{ qp }} in the rendering queue.{% endblocktrans %}
</p>
{% endif %}
<p>
{% if daemon_running and gis_lag_ok and waymarked_lag_ok%}
{% blocktrans with gis_lastupdate|timesince:utc_now as date %}All systems are operational.{% endblocktrans %}
{% else %}
{% if daemon_running and gis_lastupdate %}
{% blocktrans %}Systems are operational but renderings may not reflect the latest available OpenStreetMap data.{% endblocktrans %}
{% endif %}
{% endif %}
{% if daemon_running %}
<div class="alert alert-success">
<i class="fas fa-check"></i> {% blocktrans %}The rendering daemon is running.{% endblocktrans %}
<div class="alert alert-{{queues_overall_state}}">
<h5>Render queue states:</h5>
<ul class="list-group">
{% for key, value in queue_states.items %}
<li class="list-group-item
list-group-item-{{value.running|yesno:"success,danger,warning"}}
d-flex justify-content-between align-items-center"
>{{key}}
<span
class="badge badge-pill
badge-{{value.running|yesno:"success,danger,warning"}}"
title="{% blocktrans with size=value.size qp=value.size|pluralize %} {{size}} job{{ qp }} in the rendering queue.{% endblocktrans %}">
{% if value.size > 0 %}
{{value.size}}
{% else %}
-
{% endif %}
</span>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<div class="alert alert-danger">
<i class="fas fa-times"></i> {% blocktrans %}The rendering daemon is not running: jobs will be queued until the rendering daemon is back up.{% endblocktrans %}
</div>
{% endif %}
{% if gis_lag_ok %}
<div class="alert alert-success">
<i class="fas fa-check"></i> {% blocktrans with gis_lastupdate|timesince:utc_now as date %}The GIS database is online and up to date, <span class="tooltipped" data-original-title="{{ gis_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
<i class="fas fa-check"></i> {% blocktrans with gis_lastupdate|timesince:utc_now as date %}The GIS database is online and up to date, <span class="tooltipped" data-original-title="{{ gis_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
</div>
{% else %}
{% if gis_lastupdate %}
<div class="alert alert-warning">
<i class="fas fa-warning"></i>
{% blocktrans with gis_lastupdate|timesince:utc_now as date %}The GIS database is not up to date and was only <span class="tooltipped" data-original-title="{{ gis_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
<i class="fas fa-warning"></i>
{% blocktrans with gis_lastupdate|timesince:utc_now as date %}The GIS database is not up to date and was only <span class="tooltipped" data-original-title="{{ gis_lastupdate }}">updated {{ date }} ago</span>.{% endblocktrans %}
</div>
{% else %}
<div class="alert alert-danger">
<i class="fas fa-times"></i> {% blocktrans %}The GIS database is not available. Renderings cannot be processed at this time.{% endblocktrans %}
<i class="fas fa-times"></i> {% blocktrans %}The GIS database is not available. Renderings cannot be processed at this time.{% endblocktrans %}
</div>
{% endif %}
{% endif %}

Wyświetl plik

@ -79,9 +79,7 @@ def about(request):
return render(request,
'maposmatic/about.html',
{ 'form': form,
'queued': job_list.count()
}
{ }
)
def privacy(request):
@ -117,9 +115,7 @@ def donate(request):
return render(request,
'maposmatic/donate.html',
{ 'form': form,
'queued': job_list.count()
}
{ }
)
def donate_thanks(request):

Wyświetl plik

@ -319,8 +319,17 @@ MAP_LANGUAGES_LIST.append(("C", _(u"No localization")))
REFRESH_JOB_WAITING = 15
REFRESH_JOB_RENDERING = 10
def is_daemon_running():
return 0 == os.system('systemctl is-active maposmatic-render.service')
QUEUE_NAMES = ['default', 'api', 'multipage']
# We are having this check in the settings file as it is somewhat
# platform specific. The below implementation assumes that the
# renderer process(es) are running as systemD services which
# should be a sensible default these days.
def is_daemon_running(queue_name=None):
name = ''
if queue_name is not None:
name = "@" + queue_name
return 0 == os.system('systemctl is-active maposmatic-render%s.service' % name)
# Logging
logconfig.setup_maposmatic_logging(