Class: Invoker::CLI::Tail

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/cli/tail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(process_names) ⇒ Tail

Returns a new instance of Tail.



4
5
6
7
8
# File 'lib/invoker/cli/tail.rb', line 4

def initialize(process_names)
  verify_process_name(process_names)
  @process_names = process_names
  @unix_socket = Invoker::IPC::UnixClient.new
end

Instance Attribute Details

#process_namesObject

Returns the value of attribute process_names.



3
4
5
# File 'lib/invoker/cli/tail.rb', line 3

def process_names
  @process_names
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
# File 'lib/invoker/cli/tail.rb', line 10

def run
  socket = @unix_socket.send_and_wait('tail', process_names: process_names)
  trap('INT') { socket.close }
  loop do
    message = read_next_line(socket)
    break unless message
    puts message.tail_line
  end
end