90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/juggernaut/runner.rb', line 90
def parse_options(argv)
OptionParser.new do |opts|
opts.summary_width = 25
opts.banner = "Juggernaut (#{VERSION})\n\n",
"Usage: juggernaut [-h host] [-p port] [-P file]\n",
" [-d] [-k port] [-l file] [-e]\n",
" juggernaut --help\n",
" juggernaut --version\n"
opts.separator ""
opts.separator ""; opts.separator "Configuration:"
opts.on("-g", "--generate FILE", String, "Generate config file", "(default: #{options[:config_path]})") do |v|
options[:config_path] = File.expand_path(v) if v
generate_config_file
end
opts.on("-c", "--config FILE", String, "Path to configuration file.", "(default: #{options[:config_path]})") do |v|
options[:config_path] = File.expand_path(v)
end
opts.separator ""; opts.separator "Network:"
opts.on("-h", "--host HOST", String, "Specify host", "(default: #{options[:host]})") do |v|
options[:host] = v
end
opts.on("-p", "--port PORT", Integer, "Specify port", "(default: #{options[:port]})") do |v|
options[:port] = v
end
opts.on("-s", "--fdsize SIZE", Integer, "Set the file descriptor size an user epoll() on Linux", "(default: use select() which is limited to 1024 clients)") do |v|
options[:descriptor_table_size] = v
end
opts.separator ""; opts.separator "Daemonization:"
opts.on("-P", "--pid FILE", String, "save PID in FILE when using -d option.", "(default: #{options[:pid_path]})") do |v|
options[:pid_path] = File.expand_path(v)
end
opts.on("-d", "--daemon", "Daemonize mode") do |v|
options[:daemonize] = v
end
opts.on("-k", "--kill PORT", String, :OPTIONAL, "Kill specified running daemons - leave blank to kill all.") do |v|
options[:kill] = v
end
opts.separator ""; opts.separator "Logging:"
opts.on("-l", "--log [FILE]", String, "Path to print debugging information.", "(default: #{options[:log_path]})") do |v|
options[:log_path] = File.expand_path(v)
end
opts.on("-e", "--debug", "Run in debug mode", "(default: #{options[:debug]})") do |v|
options[:debug] = v
end
opts.separator ""; opts.separator "Permissions:"
opts.on("-u", "--user USER", Integer, "User to run as") do |user|
options[:user] = user
end
opts.on("-G", "--group GROUP", String, "Group to run as") do |group|
options[:group] = group
end
opts.separator ""; opts.separator "Miscellaneous:"
opts.on_tail("-?", "--help", "Display this usage information.") do
puts "#{opts}\n"
exit
end
opts.on_tail("-v", "--version", "Display version") do |v|
puts "Juggernaut #{VERSION}"
exit
end
end.parse!(argv)
options
end
|