Class: Sv::Status
- Inherits:
-
Object
- Object
- Sv::Status
- Defined in:
- lib/sv/status.rb
Instance Attribute Summary collapse
-
#socket_path ⇒ Object
readonly
Returns the value of attribute socket_path.
Instance Method Summary collapse
-
#initialize(socket_path) ⇒ Status
constructor
A new instance of Status.
- #running? ⇒ Boolean
- #stopped? ⇒ Boolean
- #wait_until_stopped ⇒ Object
Constructor Details
#initialize(socket_path) ⇒ Status
Returns a new instance of Status.
8 9 10 |
# File 'lib/sv/status.rb', line 8 def initialize(socket_path) @socket_path = socket_path end |
Instance Attribute Details
#socket_path ⇒ Object (readonly)
Returns the value of attribute socket_path.
6 7 8 |
# File 'lib/sv/status.rb', line 6 def socket_path @socket_path end |
Instance Method Details
#running? ⇒ Boolean
12 13 14 15 16 17 18 19 |
# File 'lib/sv/status.rb', line 12 def running? socket_path = File.realdirpath @socket_path s = UNIXSocket.new(socket_path) s.close return true rescue Errno::ECONNREFUSED, Errno::ENOENT return false end |
#stopped? ⇒ Boolean
21 22 23 |
# File 'lib/sv/status.rb', line 21 def stopped? not running? end |
#wait_until_stopped ⇒ Object
25 26 27 28 29 30 |
# File 'lib/sv/status.rb', line 25 def wait_until_stopped loop do break if not running? sleep 0.1 end end |