8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/magpie/server.rb', line 8
def parse!(args)
options = {}
opt_parser = OptionParser.new("", 24, ' ') do |opts|
opts.banner = "Usage: mag [rack options] [mag config]"
opts.separator ""
opts.separator "Rack options:"
opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s|
options[:server] = s
}
opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host|
options[:Host] = host
}
opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port|
options[:Port] = port
}
opts.on("-D", "--daemonize", "run daemonized in the background") { |d|
options[:daemonize] = d ? true : false
}
opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f|
options[:pid] = f
}
opts.on("-M", "--mode MODE", "开启magpie模式选项(snake, bird 默认模式是snake)"){ |mode|
options[:mode] = mode
}
opts.on("-L", "--log logfile", "指定日志文件"){ |logfile|
options[:log] = logfile
}
opts.separator ""
opts.separator "Common options:"
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("--version", "Show version") do
puts "Magpie #{Magpie.version}"
exit
end
end
opt_parser.parse! args
options[:yml] = args.last if args.last
options
end
|