Add some backend checks.
+import sys
from flask import Flask, render_template
from flask_celeryext import create_celery_app
@@ -66,6 +67,31 @@ def add_vary_header(response):
return response
+@app.cli.group()
+def check():
+ "Checks some backends"
+
+
+@check.command()
+def postgres():
+ "Checks database connection"
+ try:
+ db.session.execute('SELECT 1')
+ except Exception:
+ sys.exit(1)
+
+
+@check.command()
+def redis():
+ "Checks database connection"
+ try:
+ response = app.config['REDIS'].ping()
+ except Exception:
+ response = None
+ if not response:
+ sys.exit(1)
+
+
@app.cli.group()
def sync():
"Sync Jazzband data"
