2 require 'commands/servers/base'
4 unless defined?(Mongrel
)
5 puts
"PROBLEM: Mongrel is not available on your system (or not in your path)"
14 :environment => (ENV['RAILS_ENV'] || "development").dup
,
19 ARGV.clone
.options
do |opts
|
20 opts
.on("-p", "--port=port", Integer
, "Runs Rails on the specified port.", "Default: 3000") { |v
| OPTIONS
[:port] = v
}
21 opts
.on("-b", "--binding=ip", String
, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v
| OPTIONS
[:ip] = v
}
22 opts
.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS
[:detach] = true }
23 opts
.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS
[:debugger] = true }
24 opts
.on("-e", "--environment=name", String
,
25 "Specifies the environment to run this server under (test/development/production).",
26 "Default: development") { |v
| OPTIONS
[:environment] = v
}
30 opts
.on("-h", "--help", "Show this help message.") { puts opts
; exit
}
35 puts
"=> Rails #{Rails.version} application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
39 "-p", OPTIONS
[:port].to_s
,
40 "-a", OPTIONS
[:ip].to_s
,
41 "-e", OPTIONS
[:environment],
42 "-P", "#{RAILS_ROOT}/tmp/pids/mongrel.pid"
46 `mongrel_rails #{parameters.join(" ")} -d`
48 ENV["RAILS_ENV"] = OPTIONS
[:environment]
49 RAILS_ENV
.replace(OPTIONS
[:environment]) if defined?(RAILS_ENV
)
51 start_debugger
if OPTIONS
[:debugger]
53 puts
"=> Call with -d to detach"
54 puts
"=> Ctrl-C to shutdown server"
56 log
= Pathname
.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath
57 open(log
, (File
::WRONLY | File
::APPEND | File
::CREAT)) unless File
.exist
? log
58 tail_thread
= tail(log
)
63 silence_warnings
{ ARGV = parameters
}
66 tail_thread
.kill
if tail_thread