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 21 22 |
# 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_id = task_id setup_task_logging task_manager = Bosh::Director::Api::TaskManager.new @job_class = job_class @task_logger.info("Looking for task with task id #{@task_id}") @task = task_manager.find_task(@task_id) 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.
40 41 42 |
# File 'lib/bosh/director/job_runner.rb', line 40 def checkpoint @task.update(:checkpoint_time => Time.now) end |
#run(*args) ⇒ Object
Runs director job
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bosh/director/job_runner.rb', line 25 def run(*args) Config.current_job = nil @task_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) @task_logger.info("Task took #{duration} to process.") end |