Module: Iodine::Base::CLI
Overview
Command line interface. The Ruby CLI might be changed in future versions.
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
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 |
# 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[-2].to_s == '-v' || ARGV[-2].to_s == '-q') && 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 Iodine.warmup(app) if ARGV.index('-warmup') Iodine::Rack.run(app, opt) end |
#print_help ⇒ Object
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 |
# File 'lib/iodine/cli.rb', line 10 def print_help puts <<-EOS Iodine's HTTP/Websocket server version #{Iodine::VERSION} Use: iodine <options> <filename> Both <options> and <filename> are optional. Available options: -b Binding address. Default: nil (same as 0.0.0.0). -p Port number. Default: 3000. -t Number of threads. Default: CPU core count. -w Number of worker processes. Default: CPU core count. -www Public folder for static file serving. Default: nil (none). -v Log responses. Default: never log responses. -warmup Warmup invokes autoloading (lazy loading) during server startup. -tout HTTP inactivity connection timeout. Default: 40 seconds. -maxhead Maximum total headers length per HTTP request. Default: 32Kb. -maxbd Maximum Mb per HTTP message (max body size). Default: 50Mb. -maxms Maximum Bytes per Websocket message. Default: 250Kb. -ping Websocket ping interval in seconds. Default: 40 seconds. <filename> Defaults to: config.ru Example: iodine -p 80 iodine -p 8080 path/to/app/conf.ru iodine -p 8080 -w 4 -t 16 EOS end |
#try_file(filename) ⇒ Object
48 49 50 51 |
# File 'lib/iodine/cli.rb', line 48 def try_file filename return nil unless File.exist? filename return ::Rack::Builder.parse_file filename end |