1 #!/this/will/be/overwritten/or/wrapped/anyways/do/not/worry/ruby
2 # -*- encoding: binary -*-
3 require 'unicorn/launcher'
7 ENV["RACK_ENV"] ||= "development"
10 options
= { :listeners => listeners
}
11 host
, port
= Unicorn
::Const::DEFAULT_HOST, Unicorn
::Const::DEFAULT_PORT
14 opts
= OptionParser
.new("", 24, ' ') do |opts
|
15 opts
.banner
= "Usage: #{File.basename($0)} " \
16 "[ruby options] [unicorn options] [rackup config file]"
18 opts
.separator
"Ruby options:"
21 opts
.on("-e", "--eval LINE", "evaluate a LINE of code") do |line
|
22 eval line
, TOPLEVEL_BINDING
, "-e", lineno
26 opts
.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") do
30 opts
.on("-w", "--warn", "turn warnings on for your script") do
34 opts
.on("-I", "--include PATH",
35 "specify $LOAD_PATH (may be used more than once)") do |path
|
36 $LOAD_PATH.unshift(*path
.split(/:/))
39 opts
.on("-r", "--require LIBRARY",
40 "require the library, before executing your script") do |library
|
44 opts
.separator
"Rainbows!/Unicorn options:"
46 # some of these switches exist for rackup command-line compatibility,
48 opts
.on("-o", "--host HOST",
49 "listen on HOST (default: #{Unicorn::Const::DEFAULT_HOST})") do |h
|
54 opts
.on("-p", "--port PORT",
55 "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |p
|
60 opts
.on("-E", "--env RACK_ENV",
61 "use RACK_ENV for defaults (default: development)") do |e
|
65 opts
.on("-D", "--daemonize", "run daemonized in the background") do |d
|
66 daemonize
= d
? true : false
69 opts
.on("-P", "--pid FILE", "DEPRECATED") do |f
|
70 warn
"Use of --pid/-P is strongly discouraged"
71 warn
"Use the 'pid' directive in the Rainbows!/Unicorn config file instead"
75 opts
.on("-s", "--server SERVER",
76 "this flag only exists for compatibility") do |s
|
77 warn
"-s/--server only exists for compatibility with rackup"
80 # Rainbows!/Unicorn-specific stuff
81 opts
.on("-l", "--listen {HOST:PORT|PATH}",
82 "listen on HOST:PORT or PATH",
83 "this may be specified multiple times",
84 "(default: #{Unicorn::Const::DEFAULT_LISTEN})") do |address
|
88 opts
.on("-c", "--config-file FILE",
89 "Rainbows!/Unicorn-specific config file") do |f
|
90 options
[:config_file] = f
93 # I'm avoiding Unicorn-specific config options on the command-line.
94 # IMNSHO, config options on the command-line are redundant given
95 # config files and make things unnecessarily complicated with multiple
96 # places to look for a config option.
98 opts
.separator
"Common options:"
100 opts
.on_tail("-h", "--help", "Show this message") do
101 puts opts
.to_s
.gsub(/^.*DEPRECATED.*$/s
, '')
105 opts
.on_tail("-v", "--version", "Show version") do
106 puts
"Rainbows! v#{Rainbows::Const::RAINBOWS_VERSION}"
113 app
= Unicorn
.builder(ARGV[0] || 'config.ru', opts
)
114 listeners
<< "#{host}:#{port}" if set_listener
119 :unicorn_options => options
,
121 :daemonize => daemonize
,
125 Unicorn
::Launcher.daemonize
!(options
) if daemonize
126 Rainbows
.run(app
, options
)