Skip to content

Commit

Permalink
Use Rack::Server to allow the use of other webservers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Gierth committed Jan 15, 2012
1 parent 442fa5b commit 691fee5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -13,6 +13,7 @@ gem "rack-test"
gem "yajl-ruby", :git => "git://github.com/brianmario/yajl-ruby.git"
gem "thin"
gem "activesupport"
gem "hatetepe"

group :development do
gem "delorean", ">= 0"
Expand Down
17 changes: 10 additions & 7 deletions lib/fnordmetric.rb
Expand Up @@ -6,7 +6,7 @@
require 'yajl'
require 'sinatra/base'
require 'haml'
require 'thin'
require 'rack/server'

module FnordMetric

Expand All @@ -27,6 +27,7 @@ def self.default_options(opts)

opts[:inbound_stream] ||= ["0.0.0.0", "1337"]
opts[:web_interface] ||= ["0.0.0.0", "4242"]
opts[:web_interface_server] ||= "thin"

opts[:start_worker] ||= true
opts[:print_stats] ||= 3
Expand All @@ -52,14 +53,16 @@ def self.start_em(opts)
app = embedded(opts)

if opts[:web_interface]
begin
Thin::Server.start(*opts[:web_interface], app)
log "listening on http##{opts[:web_interface].join(":")}"
rescue Exception => e
log "cant start FnordMetric::App. port in use?"
server = opts[:web_interface_server].downcase
unless ["thin", "hatetepe"].include? server
raise "Need an EventMachine webserver, but #{server} isn't"
end
end

host, port = *opts[:web_interface]
Rack::Server.start :app => app, :server => server,
:Host => host, :Port => port
log "listening on http://#{host}:#{port}"
end
end
end

Expand Down

0 comments on commit 691fee5

Please sign in to comment.