Class: EasyServe::UNIXService
Constant Summary
Constants inherited
from Service
Service::SERVICE_CLASS
Instance Attribute Summary collapse
Attributes inherited from Service
#name, #pid
Instance Method Summary
collapse
Methods inherited from Service
#connect, for, #tunnelled
Constructor Details
#initialize(name, path: nil) ⇒ UNIXService
Returns a new instance of UNIXService.
61
62
63
64
|
# File 'lib/easy-serve/service.rb', line 61
def initialize name, path: nil
super name
@path = path
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
59
60
61
|
# File 'lib/easy-serve/service.rb', line 59
def path
@path
end
|
Instance Method Details
#bump! ⇒ Object
90
91
92
|
# File 'lib/easy-serve/service.rb', line 90
def bump!
@path = EasyServe.bump_socket_filename(path)
end
|
#cleanup ⇒ Object
77
78
79
80
|
# File 'lib/easy-serve/service.rb', line 77
def cleanup
super
FileUtils.remove_entry path if path
end
|
#serve(max_tries: 1, log: log) ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/easy-serve/service.rb', line 66
def serve max_tries: 1, log: log
super.tap do |svr|
found_path = svr.addr[1]
log.debug "#{inspect} is listening at #{found_path}"
if found_path != path
log.error "Unexpected path: #{found_path} != #{path}"
end
end
end
|
#try_connect ⇒ Object
82
83
84
|
# File 'lib/easy-serve/service.rb', line 82
def try_connect
UNIXSocket.new(path)
end
|
#try_serve ⇒ Object
86
87
88
|
# File 'lib/easy-serve/service.rb', line 86
def try_serve
UNIXServer.new(path)
end
|