Module: Tennpipes::Cli::Adapter

Defined in:
lib/tennpipes-base/cli/adapter.rb

Class Method Summary collapse

Class Method Details

.start(options) ⇒ Object

Start for the given options a rackup handler



6
7
8
# File 'lib/tennpipes-base/cli/adapter.rb', line 6

def start(options)
  Tennpipes.run!(options.symbolize_keys)
end

.stop(options) ⇒ Object

Method that stop (if exist) a running Tennpipes.application



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tennpipes-base/cli/adapter.rb', line 11

def stop(options)
  options.symbolize_keys!
  if File.exist?(options[:pid])
    pid = File.read(options[:pid]).to_i
    puts "=> Sending INT to process with pid #{pid}"
    begin
      Process.kill(2, pid)
    rescue Errno::ESRCH, RangeError => error
      puts error.message
      exit
    rescue Errno::EPERM => error
      puts error.message
      abort
    end
  else
    puts "=> #{options[:pid]} not found!"
    abort
  end
end