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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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
|
# File 'lib/spider-gazelle/options.rb', line 32
def self.parse(args)
options = {}
parser = OptionParser.new do |opts|
opts.on "-p", "--port PORT", Integer, "Define what port TCP port to bind to (default: 3000)" do |arg|
options[:port] = arg
end
opts.on "-h", "--host ADDRESS", "bind to address (default: 0.0.0.0)" do |arg|
options[:host] = arg
end
opts.on "-v", "--verbose", "loud output" do
options[:verbose] = true
end
opts.on "-d", "--debug", "debugging mode with lowered security and manual processes" do
options[:debug] = true
end
opts.on "-e", "--environment ENVIRONMENT", "The environment to run the Rack app on (default: development)" do |arg|
options[:environment] = arg
end
opts.on "-r", "--rackup FILE", "Load Rack config from this file (default: config.ru)" do |arg|
options[:rackup] = arg
end
opts.on "-rl", "--rack-lint", "enable rack lint on all requests" do
options[:lint] = true
end
opts.on "-m", "--mode MODE", MODES, "Either reactor, thread or inline (default: reactor)" do |arg|
options[:mode] = arg
end
opts.on "-b", "--backlog BACKLOG", Integer, "Number of pending connections allowed (default: 5000)" do |arg|
options[:backlog] = arg
end
opts.on "-t", "--use-tls PRIVATE_KEY_FILE", "Enables TLS on the port specified using the provided private key in PEM format" do |arg|
options[:tls] = true
options[:private_key] = arg
end
opts.on "-tc", "--tls-chain-file CERT_CHAIN_FILE", "The certificate chain to provide clients" do |arg|
options[:cert_chain] = arg
end
opts.on "-ts", "--tls-ciphers CIPHER_LIST", "A list of Ciphers that the server will accept" do |arg|
options[:ciphers] = arg
end
opts.on "-tv", "--tls-verify-peer", "Do we want to verify the client connections? (default: false)" do
options[:verify_peer] = true
end
opts.on "-g", "--gazelle PASSWORD", 'For internal use only' do |arg|
options[:gazelle] = arg
end
opts.on "-f", "--file IPC", 'For internal use only' do |arg|
options[:gazelle_ipc] = arg
end
opts.on "-s", "--spider PASSWORD", 'For internal use only' do |arg|
options[:spider] = arg
end
opts.on "-i", "--interactive-mode", 'Loads a multi-process version of spider-gazelle that can live update your app' do
options[:isolate] = false
end
opts.on "-c", "--count NUMBER", Integer, "Number of gazelle processes to launch (default: number of CPU cores)" do |arg|
options[:count] = arg
end
opts.on "-u", "--update", "Live migrates to a new process without dropping existing connections" do |arg|
options[:update] = true
end
opts.on "-up", "--update-password PASSWORD", "Sets a password for performing updates" do |arg|
options[:password] = arg
end
opts.on "-l", "--loglevel LEVEL", Logger::LEVELS, "Sets the log level" do |arg|
options[:loglevel] = arg
end
end
parser.banner = "sg <options> <rackup file>"
parser.on_tail "-h", "--help", "Show help" do
puts parser
exit 1
end
parser.parse!(args)
if args.last =~ /\.ru$/
options[:rackup] = args.last
end
unless options[:update]
options = DEFAULTS.merge(options)
unless File.exist? options[:rackup]
abort "No rackup found at #{options[:rackup]}"
end
options[:environment] ||= ENV['RACK_ENV'] || 'development'
ENV['RACK_ENV'] = options[:environment]
options[:isolate] = false if options[:mode] == :process
options[:mode] = :no_ipc if ::FFI::Platform.windows? && options[:mode] == :thread
end
options
end
|