feat: add chatwoot instance status in superadmin (#6045)

* feat: add chatwoot instance status in superadmin

* feat: add redis metrics to instance health page

* chore: fix rubocop

* chore: rescue redis no connection

* chore: add rspec

* chore: refactor

* feat: add instance health to /api

* chore: rescue postgres

* chore: fix spec
This commit is contained in:
Vishnu Narayanan
2023-01-30 18:37:51 +05:30
committed by GitHub
parent 747e6cacb9
commit b1af814eab
7 changed files with 120 additions and 2 deletions

View File

@@ -2,6 +2,24 @@ class ApiController < ApplicationController
skip_before_action :set_current_user, only: [:index]
def index
render json: { version: Chatwoot.config[:version], timestamp: Time.now.utc.to_formatted_s(:db) }
render json: { version: Chatwoot.config[:version],
timestamp: Time.now.utc.to_formatted_s(:db),
queue_services: redis_status,
data_services: postgres_status }
end
private
def redis_status
r = Redis.new(Redis::Config.app)
return 'ok' if r.ping
rescue Redis::CannotConnectError
'failing'
end
def postgres_status
ActiveRecord::Base.connection.active? ? 'ok' : 'failing'
rescue ActiveRecord::ConnectionNotEstablished
'failing'
end
end