iachat/app/controllers/api_controller.rb
Gabriel Jablonski 52a55827c3 chore: lint files (#2)
* chore: lint files

* chore: suppress warning

* chore: disable suggest extensions

* chore: do not stage changes in pre-commit

* chore: remove git add from FE lint and `-a` flag from rubocop on husky
2025-04-03 23:28:38 -03:00

26 lines
627 B
Ruby

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