Class: RufusSchedulerWin32::Daemon

Inherits:
Win32::Daemon
  • Object
show all
Defined in:
lib/rufus/scheduler/win32/daemon.rb

Overview

Service wrapper around rufus-scheduler

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject



48
49
50
# File 'lib/rufus/scheduler/win32/daemon.rb', line 48

def logger
  @logger ||= Logger.new(STDOUT)
end

Instance Method Details

#schedulerObject



44
45
46
# File 'lib/rufus/scheduler/win32/daemon.rb', line 44

def scheduler
  @scheduler ||= Rufus::Scheduler.new
end

#service_mainObject



11
12
13
14
15
16
17
18
# File 'lib/rufus/scheduler/win32/daemon.rb', line 11

def service_main
  logger.info 'Running Main Loop'
  while scheduler.up?
    logger.debug 'Still Running'
    sleep 10
  end
  logger.info 'Scheduler down. Exiting main loop'
end

#service_pauseObject



28
29
30
31
32
33
34
# File 'lib/rufus/scheduler/win32/daemon.rb', line 28

def service_pause
  logger.info 'Pausing scheduler service'

  scheduler.pause unless scheduler.paused?

  logger.info 'Paused scheduler service'
end

#service_resumeObject



36
37
38
39
40
41
42
# File 'lib/rufus/scheduler/win32/daemon.rb', line 36

def service_resume
  logger.info 'Resuming scheduler service'

  scheduler.resume if scheduler.paused?

  logger.info 'Resumed scheduler service'
end

#service_stopObject



20
21
22
23
24
25
26
# File 'lib/rufus/scheduler/win32/daemon.rb', line 20

def service_stop
  logger.info 'Stopping scheduler service'

  scheduler.shutdown(:wait)

  logger.info 'Service stopped'
end