module MiGA::Daemon::Base

Public Instance Methods

latency() click to toggle source

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

# File lib/miga/daemon/base.rb, line 30
def latency() runopts(:latency); end
maxjobs() click to toggle source

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

# File lib/miga/daemon/base.rb, line 34
def maxjobs() runopts(:maxjobs); end
ppn() click to toggle source

Returns Integer indicating the number of CPUs per job.

# File lib/miga/daemon/base.rb, line 38
def ppn() runopts(:ppn); end
restart(opts = []) click to toggle source

Restarts the daemon with opts.

# File lib/miga/daemon/base.rb, line 55
def restart(opts = []) daemon('restart', opts); end
runopts(k, v = nil, force = false) click to toggle source

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.

# 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
  @runopts[k]
end
shutdown_when_done?() click to toggle source

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

# File lib/miga/daemon/base.rb, line 43
def shutdown_when_done?() !!runopts(:shutdown_when_done); end
start(opts = []) click to toggle source

Initializes the daemon with opts.

# File lib/miga/daemon/base.rb, line 47
def start(opts = []) daemon('start', opts); end
status(opts = []) click to toggle source

Returns the status of the daemon with opts.

# File lib/miga/daemon/base.rb, line 59
def status(opts = []) daemon('status', opts); end
stop(opts = []) click to toggle source

Stops the daemon with opts.

# File lib/miga/daemon/base.rb, line 51
def stop(opts = []) daemon('stop', opts); end