2 require File
.dirname(__FILE__
) + '/../ruby_lib/ebb'
11 :log_file => 'log/ebb.log',
12 :pid_file => 'tmp/pids/ebb.pid'
15 opts
= OptionParser
.new
do |opts
|
16 opts
.banner
= "Usage: ebb_rails [options] start|stop"
19 opts
.separator
"Server options:"
21 opts
.on("-s", "--socket SOCKET", "listen on socket") { |socket
| options
[:socket] = socket
}
22 opts
.on("-p", "--port PORT", "use PORT (default: 3000)") { |port
| options
[:port] = port
}
23 opts
.on("-e", "--env ENV", "Rails environment (default: development)") { |env| options
[:env] = env }
24 opts
.on("-c", "--chdir PATH", "Rails root dir (default: current dir)") { |dir
| options
[:root] = dir
}
25 opts
.on("-d", "--daemonize", "Daemonize") { options
[:daemonize] = true }
26 opts
.on("-l", "--log-file FILE", "File to redirect output",
27 "(default: #{options[:log_file]})") { |file
| options
[:log_file] = file
}
28 opts
.on("-P", "--pid-file FILE", "File to store PID",
29 "(default: #{options[:pid_file]})") { |file
| options
[:pid_file] = file
}
30 opts
.on("-t", "--timeout SEC", "Request or command timeout in sec",
31 "(default: #{options[:timeout]})") { |sec
| options
[:timeout] = sec
; raise NotImplementedError
} # TODO: fix me
32 opts
.on("-u", "--user NAME", "User to run daemon as (use with -g)") { |user
| options
[:user] = user
}
33 opts
.on("-g", "--group NAME", "Group to run daemon as (use with -u)") { |group
| options
[:group] = group
}
36 opts
.separator
"Common options:"
38 opts
.on_tail("-h", "--help", "Show this message") do
43 opts
.on_tail('-v', '--version', "Show version") do
44 puts
"Ebb #{Ebb::VERSION}"
54 app
= Rack
::Adapter::Rails.new(options
)
55 server
= Ebb
::Server.new(app
, options
)
57 server
.pid_file
= options
[:pid_file]
58 server
.log_file
= options
[:log_file]
59 # server.timeout = options[:timeout]
61 if options
[:daemonize]
62 server
.change_privilege options
[:user], options
[:group] if options
[:user] && options
[:group]
69 Ebb
::Server.kill options
[:pid_file], options
[:timeout]
72 puts
"Command required"
77 abort
"Invalid command : #{ARGV[0]}"