2004-11-23 20:04:44 -05:00
|
|
|
#!/usr/local/bin/ruby
|
|
|
|
|
|
|
|
require 'webrick'
|
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
OPTIONS = {
|
|
|
|
:port => 3000,
|
2005-02-23 07:26:25 -05:00
|
|
|
:ip => "0.0.0.0",
|
2004-11-23 20:04:44 -05:00
|
|
|
:environment => "development",
|
2004-12-16 10:57:06 -05:00
|
|
|
:server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
|
2004-11-23 20:04:44 -05:00
|
|
|
:server_type => WEBrick::SimpleServer
|
|
|
|
}
|
|
|
|
|
|
|
|
ARGV.options do |opts|
|
|
|
|
script_name = File.basename($0)
|
|
|
|
opts.banner = "Usage: ruby #{script_name} [options]"
|
|
|
|
|
|
|
|
opts.separator ""
|
|
|
|
|
|
|
|
opts.on("-p", "--port=port", Integer,
|
|
|
|
"Runs Rails on the specified port.",
|
|
|
|
"Default: 3000") { |OPTIONS[:port]| }
|
|
|
|
opts.on("-b", "--binding=ip", String,
|
|
|
|
"Binds Rails to the specified ip.",
|
2005-02-27 12:13:55 -05:00
|
|
|
"Default: 0.0.0.0") { |OPTIONS[:ip]| }
|
2004-11-23 20:04:44 -05:00
|
|
|
opts.on("-e", "--environment=name", String,
|
|
|
|
"Specifies the environment to run this server under (test/development/production).",
|
|
|
|
"Default: development") { |OPTIONS[:environment]| }
|
|
|
|
opts.on("-d", "--daemon",
|
|
|
|
"Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
|
|
|
|
) { OPTIONS[:server_type] = WEBrick::Daemon }
|
|
|
|
|
|
|
|
opts.separator ""
|
|
|
|
|
|
|
|
opts.on("-h", "--help",
|
|
|
|
"Show this help message.") { puts opts; exit }
|
|
|
|
|
|
|
|
opts.parse!
|
|
|
|
end
|
|
|
|
|
|
|
|
ENV["RAILS_ENV"] = OPTIONS[:environment]
|
|
|
|
require File.dirname(__FILE__) + "/../config/environment"
|
|
|
|
require 'webrick_server'
|
|
|
|
|
2005-02-20 18:04:42 -05:00
|
|
|
OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
|
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
|
2005-02-20 18:04:42 -05:00
|
|
|
DispatchServlet.dispatch(OPTIONS)
|