class RooOnRails::Checks::Papertrail::SystemExists
Checks
that the app is declared in Papertrail
Input context
-
heroku.api_client: a connected PlatformAPI client
-
heroku.app.{env}: an existing app name.
-
papertrail.system_name.{env}: a
Papertrail
system name / token -
papertrail.client
-
papertrail.dest.host, .port
Output context:
-
papertrail.system_id.{env}
Public Instance Methods
call()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 32 def call data = context.papertrail.client.list_systems.find { |h| h['hostname'] == system_token } fail! "no system with token '#{system_token}' found on #{bold app_name}" if data.nil? if data.syslog.hostname != context.papertrail.dest.host || data.syslog.port != context.papertrail.dest.port final_fail! "system found, but is listening to #{data.syslog.hostname}:#{data.syslog.port} instead of #{context.papertrail.dest.host}:#{context.papertrail.dest.port}" end context.papertrail.system_id![env] = data.id pass "found system #{data.id} for token #{system_token}" end
fix()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 47 def fix # cause the app to log something dyno = heroku.dyno.create(app_name, command: 'date') # wait a bit 10.times do begin heroku.dyno.info(app_name, dyno['id']) sleep 0.5 rescue Excon::Error::NotFound break end end end
intro()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 28 def intro 'Checking that the app is logging to Papertrail...' end
Private Instance Methods
app_name()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 68 def app_name context.heroku.app[env] end
heroku()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 72 def heroku context.heroku.api_client end
system_token()
click to toggle source
# File lib/roo_on_rails/checks/papertrail/system_exists.rb, line 64 def system_token context.papertrail.system_name[env] end