def perform_job(*args)
      @task_logger.info('Creating job')

      job = @job_class.new(*args)
      Config.current_job = job

      job.task_id = @task_id
      job.task_checkpoint # cancelled in the queue?

      run_checkpointing

      @task_logger.info("Performing task: #{@task.inspect}")

      @task.timestamp = Time.now
      @task.started_at = Time.now
      @task.checkpoint_time = Time.now
      @task.save

      result = job.perform

      @task_logger.info('Done')
      finish_task(:done, result)

    rescue Bosh::Director::TaskCancelled => e
      log_exception(e)
      @task_logger.info("Task #{@task.id} cancelled")
      finish_task(:cancelled, 'task cancelled')
    rescue Exception => e
      log_exception(e)
      @task_logger.error("#{e}\n#{e.backtrace.join("\n")}")
      finish_task(:error, e)
    end
def perform_job(*args)
      @task_logger.info('Creating job')

      job = @job_class.new(*args)
      Config.current_job = job

      job.task_id = @task_id
      job.task_checkpoint # cancelled in the queue?

      run_checkpointing

      @task_logger.info("Performing task: #{@task.inspect}")

      @task.timestamp = Time.now
      @task.started_at = Time.now
      @task.checkpoint_time = Time.now
      @task.save

      result = job.perform

      @task_logger.info('Done')
      finish_task(:done, result)

    rescue Bosh::Director::TaskCancelled => e
      log_exception(e)
      @task_logger.info("Task #{@task.id} cancelled")
      finish_task(:cancelled, 'task cancelled')
    rescue Exception => e
      log_exception(e)
      @task_logger.error("#{e}\n#{e.backtrace.join("\n")}")
      finish_task(:error, e)
    end
Instantiates and performs director job.
 @param [Array] args Opaque list of job arguments that will be used to
   instantiate the new job object.
 @return [void]