Module: MiGA::Daemon::Base

Included in:
MiGA::Daemon
Defined in:
lib/miga/daemon/base.rb

Instance Method Summary collapse

Instance Method Details

#latencyObject

Returns Integer indicating the number of seconds to sleep between checks.



37
# File 'lib/miga/daemon/base.rb', line 37

def latency() runopts(:latency); end

#maxjobsObject

Returns Integer indicating the maximum number of concurrent jobs to run.



41
# File 'lib/miga/daemon/base.rb', line 41

def maxjobs() runopts(:maxjobs); end

#ppnObject

Returns Integer indicating the number of CPUs per job.



45
# File 'lib/miga/daemon/base.rb', line 45

def ppn() runopts(:ppn); end

#restart(opts = []) ⇒ Object

Restarts the daemon with opts.



62
# File 'lib/miga/daemon/base.rb', line 62

def restart(opts=[]) daemon('restart', opts); end

#runopts(k, v = nil, force = false) ⇒ Object

Set/get #options, where k is the Symbol of the option and v is the value (or nil to use as getter). Skips consistency tests if force. Returns new value.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/miga/daemon/base.rb', line 14

def runopts(k, v=nil, force=false)
  k = k.to_sym
  unless v.nil?
    if [:latency, :maxjobs, :ppn].include?(k)
      v = v.to_i
    elsif [:shutdown_when_done].include?(k)
      v = !!v
    end
    raise "Daemon's #{k} cannot be set to zero." if !force and v==0
    @runopts[k] = v
  end
  if k==:kill and v.nil?
    case @runopts[:type].to_s
    when 'bash' then return "kill -9 '%s'"
    when 'qsub' then return "qdel '%s'"
    else             return "canceljob '%s'"
    end
  end
  @runopts[k]
end

#shutdown_when_done?Boolean

Returns Boolean indicating if the daemon should shutdown when processing is complete.

Returns:

  • (Boolean)


50
# File 'lib/miga/daemon/base.rb', line 50

def shutdown_when_done?() !!runopts(:shutdown_when_done); end

#start(opts = []) ⇒ Object

Initializes the daemon with opts.



54
# File 'lib/miga/daemon/base.rb', line 54

def start(opts=[]) daemon('start', opts); end

#status(opts = []) ⇒ Object

Returns the status of the daemon with opts.



66
# File 'lib/miga/daemon/base.rb', line 66

def status(opts=[]) daemon('status', opts); end

#stop(opts = []) ⇒ Object

Stops the daemon with opts.



58
# File 'lib/miga/daemon/base.rb', line 58

def stop(opts=[]) daemon('stop', opts); end