Class: ProcessCommand::Socket::Receiver

Inherits:
BaseReceiver show all
Defined in:
lib/process_command/socket/receiver.rb

Constant Summary collapse

RECEIVER_QUEUE =
Queue.new

Class Method Summary collapse

Methods inherited from BaseReceiver

add_command_block, init, run_command_block

Class Method Details

.init_handlerObject



18
19
20
21
22
23
24
25
# File 'lib/process_command/socket/receiver.rb', line 18

def init_handler
  while client = @server.accept
    Thread.new do
      command = client.read
      run_command_block command
    end
  end
end

.init_listenerObject



12
13
14
15
16
# File 'lib/process_command/socket/receiver.rb', line 12

def init_listener
  path = Setting.socket_path Process.pid
  File.delete path if File.exists? path
  @server = UNIXServer.new path
end