Feature/826 healthcheck endpoint

This commit is contained in:
Alexander Strizhakov 2019-04-22 07:19:53 +00:00 committed by kaniini
commit 88f0be9693
7 changed files with 120 additions and 0 deletions

View file

@ -135,6 +135,7 @@ defmodule Pleroma.Web.Router do
post("/password_reset", UtilController, :password_reset)
get("/emoji", UtilController, :emoji)
get("/captcha", UtilController, :captcha)
get("/healthcheck", UtilController, :healthcheck)
end
scope "/api/pleroma", Pleroma.Web do

View file

@ -363,4 +363,17 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
def captcha(conn, _params) do
json(conn, Pleroma.Captcha.new())
end
def healthcheck(conn, _params) do
info = Pleroma.Healthcheck.system_info()
conn =
if info.healthy do
conn
else
Plug.Conn.put_status(conn, :service_unavailable)
end
json(conn, info)
end
end