module Epi::Cli::Concerns::Daemon

Protected Instance Methods

need_daemon!() click to toggle source
# File lib/epi/cli/commands/concerns/daemon.rb, line 8
def need_daemon!
  raise Exceptions::Fatal, 'No daemon is running' unless Epi::Daemon.running?
end
need_no_daemon!() click to toggle source
# File lib/epi/cli/commands/concerns/daemon.rb, line 12
def need_no_daemon!
  raise Exceptions::Fatal, 'Daemon is already running' if Epi::Daemon.running?
end
resume(&callback) click to toggle source
# File lib/epi/cli/commands/concerns/daemon.rb, line 21
def resume(&callback)
  begin
    Timeout::timeout(5) { sleep 0.05 while Epi::Daemon.socket_path.exist? }
  rescue Timeout::Error
    raise Exceptions::Fatal, 'Daemon failed to stop after 5 seconds'
  end
  Epi::Daemon.send :start, &callback
end
shutdown(&callback) click to toggle source
# File lib/epi/cli/commands/concerns/daemon.rb, line 16
def shutdown(&callback)
  Epi::Daemon.send :shutdown, &callback
  puts 'Shutting down ...'
end