2005-08-11 07:46:38 +02:00
|
|
|
#!/usr/bin/env ruby
|
2005-01-24 19:52:04 +01:00
|
|
|
|
|
|
|
require 'webrick'
|
|
|
|
require 'optparse'
|
|
|
|
|
|
|
|
OPTIONS = {
|
2005-08-10 08:16:15 +02:00
|
|
|
:port => 2500,
|
2005-08-09 04:20:28 +02:00
|
|
|
:ip => "0.0.0.0",
|
2005-08-10 08:16:15 +02:00
|
|
|
:environment => "production",
|
2005-08-09 04:20:28 +02:00
|
|
|
:server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
|
2007-10-08 06:16:31 +02:00
|
|
|
:server_type => WEBrick::SimpleServer,
|
|
|
|
:mime_types => WEBrick::HTTPUtils::DefaultMimeTypes.merge({
|
|
|
|
'avi' => 'video/x-msvideo',
|
|
|
|
'gz' => 'application/x-gzip',
|
|
|
|
'js' => 'application/x-javascript',
|
|
|
|
'nb' => 'application/mathematica',
|
|
|
|
'pdf' => 'application/pdf',
|
|
|
|
'svg' => 'application/svg+xml',
|
|
|
|
'tar' => 'application/x-tar',
|
|
|
|
'tex' => 'application/x-tex',
|
|
|
|
'xhtml' => 'application/xhtml+xml',
|
|
|
|
'xml' => 'application/xml',
|
|
|
|
'xslt' => 'application/xslt+xml'
|
|
|
|
})
|
2005-01-24 19:52:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ARGV.options do |opts|
|
|
|
|
script_name = File.basename($0)
|
|
|
|
opts.banner = "Usage: ruby #{script_name} [options]"
|
|
|
|
|
2005-08-09 04:20:28 +02:00
|
|
|
opts.separator ""
|
|
|
|
|
|
|
|
opts.on("-p", "--port=port", Integer,
|
2005-08-10 08:16:15 +02:00
|
|
|
"Runs Instiki on the specified port.",
|
|
|
|
"Default: 2500") { |OPTIONS[:port]| }
|
2005-08-09 04:20:28 +02:00
|
|
|
opts.on("-b", "--binding=ip", String,
|
2005-08-14 06:42:19 +02:00
|
|
|
"Binds Instiki to the specified ip.",
|
2005-08-09 04:20:28 +02:00
|
|
|
"Default: 0.0.0.0") { |OPTIONS[:ip]| }
|
|
|
|
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",
|
2005-08-14 06:42:19 +02:00
|
|
|
"Make Instiki run as a Daemon (only works if fork is available -- meaning on *nix)."
|
2005-01-24 19:52:04 +01:00
|
|
|
) { OPTIONS[:server_type] = WEBrick::Daemon }
|
|
|
|
|
2005-08-09 04:20:28 +02:00
|
|
|
opts.separator ""
|
2005-01-24 19:52:04 +01:00
|
|
|
|
2005-08-09 04:20:28 +02:00
|
|
|
opts.on("-h", "--help",
|
|
|
|
"Show this help message.") { puts opts; exit }
|
2005-01-24 19:52:04 +01:00
|
|
|
|
|
|
|
opts.parse!
|
|
|
|
end
|
|
|
|
|
2005-08-09 04:20:28 +02:00
|
|
|
ENV["RAILS_ENV"] = OPTIONS[:environment]
|
|
|
|
require File.dirname(__FILE__) + "/../config/environment"
|
|
|
|
require 'webrick_server'
|
2005-01-25 23:06:34 +01:00
|
|
|
|
2005-08-09 04:20:28 +02:00
|
|
|
OPTIONS['working_directory'] = File.expand_path(RAILS_ROOT)
|
2005-01-25 23:06:34 +01:00
|
|
|
|
2005-08-10 08:16:15 +02:00
|
|
|
puts "=> Instiki started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
|
|
|
|
puts "=> Ctrl-C to shutdown; call with --help for options" if OPTIONS[:server_type] == WEBrick::SimpleServer
|
2005-08-09 04:20:28 +02:00
|
|
|
DispatchServlet.dispatch(OPTIONS)
|