Class: Bosh::Director::JobRunner
- Defined in:
- lib/bosh/director/job_runner.rb
Instance Method Summary collapse
-
#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 23 |
# 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) @task_logger.info("Found task #{@task.inspect}") end |
Instance Method Details
#run(*args) ⇒ Object
Runs director job
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bosh/director/job_runner.rb', line 26 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 |