Class: MelissaData::Server::Unix

Inherits:
Base
  • Object
show all
Defined in:
lib/melissadata/server/unix.rb

Instance Attribute Summary

Attributes inherited from Base

#server

Instance Method Summary collapse

Methods inherited from Base

#address_object, #data, #email_object, #geo_object, #initialize, #input, #ip_object, #name_object, #phone_object, #process, #process_address, #process_email, #process_geo, #process_ip, #process_name, #process_phone, #setup, #version

Constructor Details

This class inherits a constructor from MelissaData::Server::Base

Instance Method Details

#runObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/melissadata/server/unix.rb', line 6

def run
  trap("INT")  { self.stop }
  trap("TERM") { self.stop }

  @socket_file = MelissaData::DEFAULT_SOCKET_FILE
  File.delete @socket_file if File.exists? @socket_file
  listener = MessagePack::RPC::UNIXServerTransport.new @socket_file
  server.listen(listener, self)
  puts "== MelissaData Unix server is running - socket file: #{@socket_file}"
  server.run
end

#stopObject



18
19
20
21
22
# File 'lib/melissadata/server/unix.rb', line 18

def stop
  puts "== Stopping MelissaData Unix server"
  server.stop
  File.delete @socket_file if File.exists? @socket_file
end