Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
status check: check redis (closes #120)
Browse files Browse the repository at this point in the history
  • Loading branch information
codl committed Mar 13, 2021
1 parent f10b9da commit 521cd7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 12 additions & 5 deletions routes/api.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
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
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',))
Expand Down
4 changes: 3 additions & 1 deletion routes/misc.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 521cd7b

Please sign in to comment.