Module: Daemon::Runner::Status

Defined in:
lib/onapp/engine/runner/status.rb

Constant Summary

KEY =
"#{Daemon::PROCESS_NAME}:%s"

Class Method Summary (collapse)

Class Method Details

+ (Object) get(hostname = current_hostname)



11
12
13
14
# File 'lib/onapp/engine/runner/status.rb', line 11

def get(hostname = current_hostname)
  value = redis.get(KEY % hostname)
  JSON.parse(value) if value
end

+ (Object) start_updating



16
17
18
19
20
# File 'lib/onapp/engine/runner/status.rb', line 16

def start_updating
  pid = Process.pid
  Redis::FadingValue.set(KEY % current_hostname,
                         ->{ JSON.generate(Daemon::Runner.status) if Process.pid == pid })
end

+ (Object) stop_updating



22
23
24
# File 'lib/onapp/engine/runner/status.rb', line 22

def stop_updating
  Redis::FadingValue.delete(KEY % current_hostname)
end