mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Add system notifications service to health check endpoint [SCI-3522]
This commit is contained in:
parent
94b220172d
commit
552f69b9b1
2 changed files with 13 additions and 0 deletions
|
|
@ -36,6 +36,11 @@ module Api
|
|||
def health
|
||||
User.new && Team.new && Project.new
|
||||
User.first if params[:db]
|
||||
if Rails.application.secrets.system_notifications_uri.present? &&
|
||||
Rails.application.secrets.system_notifications_channel.present? &&
|
||||
!Notifications::SyncSystemNotificationsService.available?
|
||||
return render plain: 'SYSTEM NOTIFICATIONS SERVICE CHECK FAILED', status: :error
|
||||
end
|
||||
render plain: 'RUNNING'
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ module Notifications
|
|||
@errors.none?
|
||||
end
|
||||
|
||||
def self.available?
|
||||
channel = Rails.application.secrets.system_notifications_channel
|
||||
query = { query: { last_sync_timestamp: Time.now.to_i, channels_slug: channel },
|
||||
headers: { 'accept': 'application/vnd.system-notifications.1+json' } }
|
||||
response = get('/api/system_notifications', query)
|
||||
response.code < Rack::Utils::SYMBOL_TO_STATUS_CODE[:bad_request]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def call_api
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue