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
|
# File 'lib/iodine/cli.rb', line 53
def call
if ARGV[0] =~ /(\-\?)|(help)|(\?)|(h)|(\-h)$/
return print_help
end
app, opt = nil, nil
filename = ((ARGV[-2].to_s[0] != '-' || ARGV[-2].to_s == '-warmup') && ARGV[-1].to_s[0] != '-' && ARGV[-1])
if filename
app, opt = try_file filename;
unless opt
puts "* Couldn't find #{filename}\n testing for config.ru\n"
app, opt = try_file "config.ru"
end
else
app, opt = try_file "config.ru";
end
unless opt
puts "WARNING: Ruby application not found#{ filename ? " - missing both #{filename} and config.ru" : " - missing config.ru"}."
if ARGV.index('-www') && ARGV[ARGV.index('-www') + 1]
puts " Running only static file service."
opt = ::Rack::Server::Options.new.parse!([])
else
puts "For help run:"
puts " iodine -?"
return
end
end
if ARGV.index('-maxbd') && ARGV[ARGV.index('-maxbd') + 1]
Iodine::Rack.max_body_size = ARGV[ARGV.index('-maxbd') + 1].to_i
end
if ARGV.index('-maxms') && ARGV[ARGV.index('-maxms') + 1]
Iodine::Rack.max_msg_size = ARGV[ARGV.index('-maxms') + 1].to_i
end
if ARGV.index('-ping') && ARGV[ARGV.index('-ping') + 1]
Iodine::Rack.ws_timeout = ARGV[ARGV.index('-ping') + 1].to_i
end
if ARGV.index('-www') && ARGV[ARGV.index('-www') + 1]
Iodine::Rack.public = ARGV[ARGV.index('-www') + 1]
end
if ARGV.index('-tout') && ARGV[ARGV.index('-tout') + 1]
Iodine::Rack.timeout = ARGV[ARGV.index('-tout') + 1].to_i
puts "WARNNING: Iodine::Rack.timeout set to 0 (ignored, timeout will be ~5 seconds)."
end
Iodine::Rack.log = true if ARGV.index('-v')
Iodine::Rack.log = false if ARGV.index('-q')
Iodine.warmup(app) if ARGV.index('-warmup')
Iodine::Rack.run(app, opt)
end
|