Skip to content

Commit

Permalink
feat: enable configuration of custom maintenance message
Browse files Browse the repository at this point in the history
  • Loading branch information
kikkomep committed Nov 20, 2023
1 parent fdb1f7e commit db0e599
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions k8s/templates/settings.secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ stringData:
{{- end }}
{{- end }}
# Maintenance Mode Settings
{{- if .Values.maintenanceMode.enabled -}}
MAINTENANCE_MODE={{.Values.maintenanceMode.enabled}}
MAINTENANCE_MODE_MAIN_MESSAGE={{.Values.maintenanceMode.mainMessage}}
MAINTENANCE_MODE_SECONDARY_MESSAGE={{.Values.maintenanceMode.secondaryMessage}}
{{- end }}
# Set admin credentials
LIFEMONITOR_ADMIN_PASSWORD={{ .Values.lifemonitor.administrator.password }}
Expand Down
3 changes: 3 additions & 0 deletions k8s/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ fullnameOverride: ""
# manage maintenance mode
maintenanceMode:
enabled: false
# mainMessage: "We're busy updating the Life-Monitor service for you."
# secondaryMessage: "We'll be back shortly."

# The name and port number of the server (e.g.: 'lm.local:8000'),
# used as base_url on all the links returned by the API
externalServerName: &hostname api.lifemonitor.eu
Expand Down
4 changes: 3 additions & 1 deletion lifemonitor/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def openapi():
def maintenance():
if not app.config.get("MAINTENANCE_MODE", False):
return redirect(url_for("index"))
return render_template("maintenance/maintenance.j2")
return render_template("maintenance/maintenance.j2",
main_message=app.config.get("MAINTENANCE_MODE_MAIN_MESSAGE", None),
secondary_message=app.config.get("MAINTENANCE_MODE_SECONDARY_MESSAGE", None))

@app.before_request
def set_request_start_time():
Expand Down
14 changes: 9 additions & 5 deletions lifemonitor/templates/maintenance/maintenance.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@
<img src="{{ url_for('static', filename='img/icons/maintenance-2.png') }}" width="280px">
</div>

{% if not main_message %}
<!-- Set the generic maintenance message -->
<h3 class="font-weight-light text-primary text-center mx-auto my-5">
We're busy updating the
<span style="font-style: italic; font-family: Baskerville,Baskerville Old Face,Hoefler Text,Garamond,Times New Roman,serif;">Life</span><span class="small" style="font-size: 75%; margin: 0 -1px 0 1px;">-</span><span style="font-weight: bold; font-family: Gill Sans,Gill Sans MT,Calibri,sans-serif;">Monitor</span>
service for you. <br>Please check back soon!
</h3>
{% else %}
<h3 class="font-weight-light text-primary text-center mx-auto my-5">
{{ main_message }}
</h3>
{% endif %}

<!-- Set the generic maintenance message -->
{% if message %}
<!-- Set the secondary maintenance message -->
{% if secondary_message %}
<h4 class="font-weight-light text-muted text-center mx-auto my-5">
We're busy updating the
<span style="font-style: italic; font-family: Baskerville,Baskerville Old Face,Hoefler Text,Garamond,Times New Roman,serif;">Life</span><span class="small" style="font-size: 75%; margin: 0 -1px 0 1px;">-</span><span style="font-weight: bold; font-family: Gill Sans,Gill Sans MT,Calibri,sans-serif;">Monitor</span>
service for you. <br>Please check back soon!
{{ secondary_message }}
</h4>
{% endif %}

Expand Down
2 changes: 2 additions & 0 deletions settings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ LOG_LEVEL=INFO # default: 'INFO' on production, 'DEBUG' on development

# Manage the maintenance mode
# MAINTENANCE_MODE=True # default: False
# MAINTENANCE_MODE_MAIN_MESSAGE="We're busy updating the Life-Monitor service for you.Please check back soon!"
# MAINTENANCE_MODE_SECONDARY_MESSAGE="We are currently performing maintenance on the LifeMonitor service. Please try again later."

# The name and port number of the back-end server (e.g., 'localhost:8000').
# If the back-end is served through a reverse proxy,
Expand Down

0 comments on commit db0e599

Please sign in to comment.