Class: BatchKit::Database::JobRun

Inherits:
Object
  • Object
show all
Defined in:
lib/batch-kit/database/models.rb

Overview

Records details of job runs

Instance Method Summary collapse

Constructor Details

#initialize(job_run) ⇒ JobRun

Returns a new instance of JobRun.



306
307
308
309
310
311
# File 'lib/batch-kit/database/models.rb', line 306

def initialize(job_run)
    super(job_id: job_run.job_id, job_instance: job_run.instance,
          job_version: job_run.job_version, job_run_by: job_run.run_by,
          job_cmd_line: job_run.cmd_line, job_start_time: job_run.start_time,
          job_status: job_run.status.to_s.upcase, job_pid: job_run.pid)
end

Instance Method Details

#job_end(job_run) ⇒ Object



320
321
322
323
324
325
326
# File 'lib/batch-kit/database/models.rb', line 320

def job_end(job_run)
    self.job_end_time = job_run.end_time
    self.job_status = job_run.status.to_s.upcase
    self.job_pid = nil
    self.job_exit_code = job_run.exit_code
    self.save
end

#job_start(job_run) ⇒ Object



314
315
316
317
# File 'lib/batch-kit/database/models.rb', line 314

def job_start(job_run)
    self.save
    job_run.job_run_id = self.job_run
end

#timeoutObject



329
330
331
332
333
334
335
336
337
# File 'lib/batch-kit/database/models.rb', line 329

def timeout
    self.job_end_time = Time.now
    self.job_status = 'TIMEOUT'
    self.job_pid = nil
    self.job_exit_code = -1
    self.save

    Job[self.job_id].job_timeout(self)
end