Class: Invoker::IPC::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/invoker/ipc/server.rb

Constant Summary collapse

SOCKET_PATH =
"/tmp/invoker"

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



7
8
9
10
11
12
# File 'lib/invoker/ipc/server.rb', line 7

def initialize
  @open_clients = []
  Socket.unix_server_loop(SOCKET_PATH) do |sock, client_addrinfo|
    Thread.new { process_client(sock) }
  end
end

Instance Method Details

#clean_old_socketObject



14
15
16
17
18
# File 'lib/invoker/ipc/server.rb', line 14

def clean_old_socket
  if File.exist?(SOCKET_PATH)
    FileUtils.rm(SOCKET_PATH, :force => true)
  end
end

#process_client(client_socket) ⇒ Object



20
21
22
23
# File 'lib/invoker/ipc/server.rb', line 20

def process_client(client_socket)
  client = Invoker::IPC::ClientHandler.new(client_socket)
  client.read_and_execute
end