Class: Custodian::CLI
- Inherits:
-
Object
- Object
- Custodian::CLI
- Defined in:
- lib/custodian/cli.rb
Overview
The CLI class encapsulates Custodian’s command-line interface.
Constant Summary collapse
- DEFAULT_PORT =
5100
Instance Method Summary collapse
-
#initialize(arguments) ⇒ CLI
constructor
Create a new command-line interface.
Constructor Details
#initialize(arguments) ⇒ CLI
Create a new command-line interface.
arguments - An Array of String objects describing arguments
passed to the program (see CLI#parse).
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 |
# File 'lib/custodian/cli.rb', line 16 def initialize(arguments) = parse arguments if samplers = [:samplers] load_samplers samplers end if .include? :daemonize deamonize end if pidfile = [:pidfile] write_pidfile pidfile end log "Custodian is accepting connections on port #{[:port]}" compatible_samplers = Custodian::Samplers.compatible incompatible_samplers = Custodian::Samplers.incompatible log "#{compatible_samplers.count} compatible samplers." compatible_samplers.each do |s| log " - #{s.description}" end log "#{incompatible_samplers.count} incompatible samplers." incompatible_samplers.each do |s| log " - #{s.description}" end log "CTRL+C to stop" Thin::Logging.silent = true Thin::Server.start '0.0.0.0', [:port] do use Rack::CommonLogger use Rack::ShowExceptions use Rack::Auth::Basic do |username, password| [username, password] == [[:username], [:password]] end if .include? :username run Custodian::API.new end end |