Permalink
Browse files

accept -p $PORT argument to bin/momentum

  • Loading branch information...
1 parent 58d93c4 commit e1776ed642d75b1c8a5a0d02389c100b1e80d14c @jonasschneider committed Jan 6, 2012
Showing with 9 additions and 6 deletions.
  1. +7 −4 bin/momentum
  2. +2 −2 lib/momentum.rb
View
@@ -4,13 +4,16 @@ require "rack"
EM.run {
wrap = ARGV.shift != '--plain'
- app = Rack::Server.new.app
+ serv = Rack::Server.new
+ app = serv.app
+ port = serv.options[:Port]
if wrap
app = Momentum::Adapters::Defer.new(app)
end
-
- Momentum.start(app)
- puts ">> Momentum running on 0.0.0.0:5555"
+
+ puts ">> Momentum running on 0.0.0.0:#{port}"
+
+ Momentum.start(app, port)
trap(:INT) {
puts ">> Exiting."
EventMachine::stop_event_loop
View
@@ -21,13 +21,13 @@ module Momentum
REJECTED_HEADERS = ['Accept-Ranges', 'Connection', 'P3p', 'Ppserver',
'Server', 'Transfer-Encoding', 'Vary']
- def self.start(backend_or_app)
+ def self.start(backend_or_app, port = 5555)
if backend_or_app.respond_to? :prepare
backend = backend_or_app
elsif backend_or_app.respond_to? :call
backend = Momentum::Backend.new(backend_or_app)
end
- EventMachine.start_server('0.0.0.0', 5555, Momentum::Connection) do |sess|
+ EventMachine.start_server('0.0.0.0', port, Momentum::Connection) do |sess|
sess.backend = backend
end
end

0 comments on commit e1776ed

Please sign in to comment.