Class: Bosh::Director::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initialize(scheduled_jobs = [], options = {}) ⇒ Scheduler

Returns a new instance of Scheduler.



5
6
7
8
9
10
11
12
13
# File 'lib/bosh/director/scheduler.rb', line 5

def initialize(scheduled_jobs=[], options={})
  if scheduled_jobs.nil? || scheduled_jobs.is_a?(Array)
    @scheduled_jobs = scheduled_jobs
    @scheduler = options.fetch(:scheduler) { Rufus::Scheduler::PlainScheduler.new }
    @queue = options.fetch(:queue) { JobQueue.new }
  else
    raise 'scheduled_jobs must be an array'
  end
end

Instance Method Details

#loggerObject



27
28
29
# File 'lib/bosh/director/scheduler.rb', line 27

def logger
  @logger ||= Config.logger
end

#start!Object



15
16
17
18
19
20
# File 'lib/bosh/director/scheduler.rb', line 15

def start!
  logger.info('starting scheduler')
  add_jobs unless @added_already
  @scheduler.start
  @scheduler.join
end

#stop!Object



22
23
24
25
# File 'lib/bosh/director/scheduler.rb', line 22

def stop!
  logger.info('stopping scheduler')
  @scheduler.stop
end