Class: Lepus::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/lepus/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/lepus/cli.rb', line 5

def self.exit_on_failure?
  true
end

Instance Method Details

#start(*consumers) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lepus/cli.rb', line 17

def start(*consumers)
  opts = (@options || {}).transform_keys(&:to_sym)

  if (list = consumers.flat_map { |c| c.split(",") }.map(&:strip).uniq.sort).any?
    opts[:consumers] = list
  end

  if (logfile = opts.delete(:logfile))
    Lepus.logger = Logger.new(logfile)
  end
  if opts.delete(:debug)
    Lepus.logger.level = Logger::DEBUG
  end

  Lepus::Supervisor.start(**opts)
end

#webObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/lepus/cli.rb', line 37

def web
  port = (options[:port] || 9292).to_i
  host = options[:host] || "0.0.0.0"

  puts "Starting Lepus Web dashboard on http://#{host}:#{port}"
  puts "Press Ctrl+C to stop"

  if system("which rackup > /dev/null 2>&1")

    exec "rackup -p #{port} -o #{host} #{__dir__}/../../config.ru"
  else
    puts <<~MSG
      Rack is not installed. Please install it using the following command:

          gem install rack

      Then run the web dashboard again.
    MSG
  end
end