Class: Paradeiser::Scheduler

Inherits:
Object
  • Object
show all
Extended by:
Executor
Defined in:
lib/paradeiser/models/scheduler.rb

Constant Summary

Constants included from Executor

Executor::BIN_PAR

Class Method Summary collapse

Methods included from Executor

at, exec, queue

Class Method Details

.add(command, minutes) ⇒ Object



19
20
21
22
23
# File 'lib/paradeiser/models/scheduler.rb', line 19

def add(command, minutes)
  _, err = exec("echo #{BIN_PAR} #{command} | #{at} -q #{queue} now + #{minutes} minutes")
  id = parse_add(err.chomp)
  Job.new(id)
end

.clearObject



25
26
27
28
29
30
# File 'lib/paradeiser/models/scheduler.rb', line 25

def clear
  if list.any? # On Linux, at must not be called with an empty job list.
    job_ids = list.map{|j| j.id}.join(' ')
    exec("#{at} -q #{queue} -r #{job_ids}")
  end
end

.listObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/paradeiser/models/scheduler.rb', line 8

def list
  out, _ = exec("#{at} -l -q #{queue}")

  out.lines.map do |line|
    id = parse_list(line)
    Job.new(id)
  end.select do |job|
    job.ours?
  end
end