Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
Use sinatra's configuration settings instead of a constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert committed Oct 3, 2011
1 parent c49482d commit 2574769
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions github-services.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
:port => ARGV.first || 8080, :port => ARGV.first || 8080,
:logging => true :logging => true


HOSTNAME = `hostname`.chomp

begin begin
require 'mongrel' require 'mongrel'
Service::App.set :server, 'mongrel' Service::App.set :server, 'mongrel'
Expand Down
7 changes: 5 additions & 2 deletions lib/app.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,8 @@
# The Sinatra App that handles incoming events. # The Sinatra App that handles incoming events.
class Service::App < Sinatra::Base class Service::App < Sinatra::Base

set :hostname, lambda { %x{hostname} }

# Hooks the given Service to a Sinatra route. # Hooks the given Service to a Sinatra route.
# #
# svc - Service instance. # svc - Service instance.
Expand Down Expand Up @@ -58,7 +61,7 @@ def report_exception(exception)
'app' => 'github-services', 'app' => 'github-services',
'type' => 'exception', 'type' => 'exception',
'class' => exception.class.to_s, 'class' => exception.class.to_s,
'server' => HOSTNAME, 'server' => settings.hostname,
'message' => exception.message[0..254], 'message' => exception.message[0..254],
'backtrace' => backtrace.join("\n"), 'backtrace' => backtrace.join("\n"),
'rollup' => Digest::MD5.hexdigest(exception.class.to_s + backtrace[0]) 'rollup' => Digest::MD5.hexdigest(exception.class.to_s + backtrace[0])
Expand All @@ -75,7 +78,7 @@ def report_exception(exception)
data['class'] = 'Service::Error' data['class'] = 'Service::Error'
end end


if HOSTNAME =~ /^sh1\.(rs|stg)\.github\.com$/ if settings.hostname =~ /^sh1\.(rs|stg)\.github\.com$/
# run only in github's production environment # run only in github's production environment
Net::HTTP.new('haystack', 80). Net::HTTP.new('haystack', 80).
post('/async', "json=#{Rack::Utils.escape(data.to_json)}") post('/async', "json=#{Rack::Utils.escape(data.to_json)}")
Expand Down

0 comments on commit 2574769

Please sign in to comment.