123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- class MonitoringController < ApplicationController
- prepend_before_action { authorize! }
- prepend_before_action -> { authentication_check }, except: %i[health_check status amount_check]
- prepend_before_action -> { authentication_check_only }, only: %i[health_check status amount_check]
- skip_before_action :verify_csrf_token
- def health_check
- health_status = MonitoringHelper::HealthChecker.new
- health_status.check_health
- result = {
- healthy: health_status.healthy?,
- message: health_status.message,
- issues: health_status.response.issues,
- actions: health_status.response.actions,
- }
-
- if authorized? policy_record, :token?
- result[:token] = Setting.get('monitoring_token')
- end
- render json: result
- end
- def status
- render json: MonitoringHelper::Status.new.fetch_status
- end
- def amount_check
- render json: MonitoringHelper::AmountCheck.new(params).check_amount
- end
- def token
- token = SecureRandom.urlsafe_base64(40)
- Setting.set('monitoring_token', token)
- result = {
- token: token,
- }
- render json: result, status: :created
- end
- def restart_failed_jobs
- Scheduler.restart_failed_jobs
- render json: {}, status: :ok
- end
- end
|