Class: Bosh::Director::JobRunner
- Defined in:
- lib/bosh/director/job_runner.rb
Instance Method Summary collapse
-
#checkpoint ⇒ void
Task checkpoint: updates timestamp so running task isn’t marked as timed out.
-
#initialize(job_class, task_id) ⇒ JobRunner
constructor
A new instance of JobRunner.
-
#run(*args) ⇒ Object
Runs director job.
Constructor Details
#initialize(job_class, task_id) ⇒ JobRunner
Returns a new instance of JobRunner.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bosh/director/job_runner.rb', line 8 def initialize(job_class, task_id) unless job_class.kind_of?(Class) && job_class <= Jobs::BaseJob raise DirectorError, "Invalid director job class `#{job_class}'" end task_manager = Bosh::Director::Api::TaskManager.new @job_class = job_class @task = task_manager.find_task(task_id) setup_logging end |
Instance Method Details
#checkpoint ⇒ void
This method returns an undefined value.
Task checkpoint: updates timestamp so running task isn’t marked as timed out.
38 39 40 |
# File 'lib/bosh/director/job_runner.rb', line 38 def checkpoint @task.update(:checkpoint_time => Time.now) end |
#run(*args) ⇒ Object
Runs director job
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bosh/director/job_runner.rb', line 23 def run(*args) Config.current_job = nil @debug_logger.info("Starting task: #{@task.id}") started_at = Time.now with_thread_name("task:#{@task.id}") { perform_job(*args) } duration = Duration.duration(Time.now - started_at) @debug_logger.info("Task took #{duration} to process.") end |