Class: Uc::Status
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logger
#event_queue, event_stream, #event_stream, logger, #logger, stderr, #stderr
#cmd, #kill, #process_running?
Constructor Details
#initialize(unicorn_paths, use_pid: false) ⇒ Status
13
14
15
16
|
# File 'lib/uc/status.rb', line 13
def initialize(unicorn_paths, use_pid: false)
@paths = unicorn_paths
@use_pid = use_pid
end
|
Instance Attribute Details
#paths ⇒ Object
Returns the value of attribute paths.
10
11
12
|
# File 'lib/uc/status.rb', line 10
def paths
@paths
end
|
#use_pid ⇒ Object
Returns the value of attribute use_pid.
11
12
13
|
# File 'lib/uc/status.rb', line 11
def use_pid
@use_pid
end
|
Instance Method Details
#pid ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/uc/status.rb', line 23
def pid
pid = pid_from_file
if pid_valid?
return pid
else
logger.debug "pids holding unicorn.lock => #{fuser_pids.join(' ')}"
logger.debug "pid from file => #{pid}"
raise ::Uc::Error, "stale pid #{pid}"
end
end
|
#pid_from_file ⇒ Object
34
35
36
|
# File 'lib/uc/status.rb', line 34
def pid_from_file
@pid_from_file ||= read_pid
end
|
#running? ⇒ Boolean
18
19
20
21
|
# File 'lib/uc/status.rb', line 18
def running?
return process_running? pid if use_pid
not ex_lock_available?
end
|
#stopped? ⇒ Boolean
38
39
40
|
# File 'lib/uc/status.rb', line 38
def stopped?
not running?
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/uc/status.rb', line 42
def to_s
status = ( running? ? "Running pid #{pid}" : "Stopped" )
end
|