Class: Sv::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/sv/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_pathObject (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

Returns:

  • (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

Returns:

  • (Boolean)


21
22
23
# File 'lib/sv/status.rb', line 21

def stopped?
  not running?
end

#wait_until_stoppedObject



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