Class: OsCtld::SendReceive::Server

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/osctld/send_receive/server.rb

Defined Under Namespace

Classes: ClientHandler

Instance Method Summary collapse

Instance Method Details

#assets(add) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/osctld/send_receive/server.rb', line 45

def assets(add)
  add.socket(
    SendReceive::SOCKET,
    desc: 'Socket for send/receive control',
    user: SendReceive::UID,
    group: 0,
    mode: 0o600
  )
end

#startObject



30
31
32
33
34
35
36
37
# File 'lib/osctld/send_receive/server.rb', line 30

def start
  socket = UNIXServer.new(SendReceive::SOCKET)
  File.chown(SendReceive::UID, 0, SendReceive::SOCKET)
  File.chmod(0o600, SendReceive::SOCKET)

  @server = Generic::Server.new(socket, ClientHandler)
  @thread = Thread.new { @server.start }
end

#stopObject



39
40
41
42
43
# File 'lib/osctld/send_receive/server.rb', line 39

def stop
  @server.stop
  @thread.join
  File.unlink(SendReceive::SOCKET)
end