From d35246c4490bcca4831b85d23049c04ffff58758 Mon Sep 17 00:00:00 2001 From: Alex S Date: Mon, 22 Apr 2019 17:00:06 +0700 Subject: [PATCH] added healthcheck setting to instance config --- config/config.exs | 3 ++- docs/config.md | 1 + .../web/twitter_api/controllers/util_controller.ex | 9 +++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/config.exs b/config/config.exs index 9f2244222..b11e4c680 100644 --- a/config/config.exs +++ b/config/config.exs @@ -230,7 +230,8 @@ config :pleroma, :instance, welcome_user_nickname: nil, welcome_message: nil, max_report_comment_size: 1000, - safe_dm_mentions: false + safe_dm_mentions: false, + healthcheck: false config :pleroma, :markup, # XXX - unfortunately, inline images must be enabled by default right now, because diff --git a/docs/config.md b/docs/config.md index ccf744f42..d8eb4f8b5 100644 --- a/docs/config.md +++ b/docs/config.md @@ -103,6 +103,7 @@ config :pleroma, Pleroma.Emails.Mailer, * `welcome_user_nickname`: The nickname of the local user that sends the welcome message. * `max_report_comment_size`: The maximum size of the report comment (Default: `1000`) * `safe_dm_mentions`: If set to true, only mentions at the beginning of a post will be used to address people in direct messages. This is to prevent accidental mentioning of people when talking about them (e.g. "@friend hey i really don't like @enemy"). (Default: `false`) +* `healthcheck`: if set to true, system data will be shown on ``/api/pleroma/healthcheck``. ## :logger * `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog, and `Quack.Logger` to log to Slack diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index d0bf3a315..1122e6c5d 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -365,10 +365,15 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do end def healthcheck(conn, _params) do - info = Pleroma.Healthcheck.system_info() + info = + if Pleroma.Config.get([:instance, :healthcheck]) do + Pleroma.Healthcheck.system_info() + else + %{} + end conn = - if info.healthy do + if info[:healthy] do conn else Plug.Conn.put_status(conn, :service_unavailable)