mirror of
https://github.com/codl/forget
synced 2024-12-26 15:13:04 +01:00
status check: check redis (closes #120)
This commit is contained in:
parent
f10b9dac80
commit
521cd7b1dc
@ -1,4 +1,4 @@
|
||||
from app import app, db
|
||||
from app import app, db, imgproxy
|
||||
from libforget.auth import require_auth_api, get_viewer
|
||||
from flask import jsonify, redirect, make_response, request, Response
|
||||
from model import Account
|
||||
@ -6,13 +6,20 @@ import libforget.settings
|
||||
import libforget.json
|
||||
import random
|
||||
|
||||
@app.route('/api/health_check')
|
||||
def health_check():
|
||||
@app.route('/api/health_check') # deprecated 2021-03-12
|
||||
@app.route('/api/status_check')
|
||||
def api_status_check():
|
||||
try:
|
||||
db.session.execute('SELECT 1')
|
||||
return 'ok'
|
||||
except Exception:
|
||||
return ('bad', 500)
|
||||
return ('PostgreSQL bad', 500)
|
||||
|
||||
try:
|
||||
imgproxy.redis.set('forget-status-check', 'howdy', ex=5)
|
||||
except Exception:
|
||||
return ('Redis bad', 500)
|
||||
|
||||
return 'OK'
|
||||
|
||||
|
||||
@app.route('/api/settings', methods=('PUT',))
|
||||
|
@ -1,5 +1,5 @@
|
||||
from app import app, db, sentry
|
||||
from flask import g, render_template, make_response, redirect
|
||||
from flask import g, render_template, make_response, redirect, request
|
||||
import version
|
||||
import libforget.version
|
||||
from libforget.auth import get_viewer_session, set_session_cookie
|
||||
@ -48,6 +48,8 @@ def not_found(e):
|
||||
|
||||
@app.errorhandler(500)
|
||||
def internal_server_error(e):
|
||||
if request.endpoint and request.endpoint.startswith('api_'):
|
||||
return e.get_response()
|
||||
return (render_template('500.html', e=e), 500)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user