Class: Plux::Server

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

Constant Summary collapse

Active =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, thread:) ⇒ Server

Returns a new instance of Server.



12
13
14
15
# File 'lib/plux/server.rb', line 12

def initialize(name, thread: )
  @name = name
  @thread = thread
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/plux/server.rb', line 7

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



7
8
9
# File 'lib/plux/server.rb', line 7

def pid
  @pid
end

Instance Method Details

#boot(block) ⇒ Object



17
18
19
20
21
22
# File 'lib/plux/server.rb', line 17

def boot(block)
  Plux.lock_pid_file(name) do |file|
    start_server_if_not_pid(file, block)
  end
  self
end

#closeObject



24
25
26
# File 'lib/plux/server.rb', line 24

def close
  Process.kill('TERM', pid) rescue Errno::ESRCH
end

#connectObject



28
29
30
# File 'lib/plux/server.rb', line 28

def connect
  Client.new(name)
end