Module: Baal::Commands

Included in:
Daemon
Defined in:
lib/baal/commands.rb

Overview

Commands contains all of the necessary methods to perform all of the possible start-stop-daemon commands.

Constant Summary collapse

COMMANDS =

Hash constant containing all possible commands.

{
  start: '--start',
  stop:  '--stop',
  status: '--status',
  help: '--help',
  version: '--version'
}.freeze

Instance Method Summary collapse

Instance Method Details

#helpObject

Command that shows cli help information and then exits.



71
72
73
74
75
# File 'lib/baal/commands.rb', line 71

def help
  @commands_and_opts.unshift COMMANDS[:help]
  include_multiple_commands?
  self
end

#startObject

Command that attempts to start a process specified through an option. Initially, it will check whether or not a specified process (through an option) exits. Then it will do one of the following:

  1. If a specified process already exists then it will do nothing and exit with an error status of 1 (or 0 if oknodo option is specified).

  2. If a matching process does not exist, then it will start an instance of one using one of the following options:

    1. exec: an absolute pathname to an executable

    II. start_as: a path_name to a process



30
31
32
33
34
# File 'lib/baal/commands.rb', line 30

def start
  @commands_and_opts.unshift COMMANDS[:start]
  include_multiple_commands?
  self
end

#statusObject

Command that checks for whether or not a process specified by an option exists. An exit code is returned accord to the LSB Init Script Actions. TODO: provide better error messages based on LSB.



64
65
66
67
68
# File 'lib/baal/commands.rb', line 64

def status
  @commands_and_opts.unshift COMMANDS[:status]
  include_multiple_commands?
  self
end

#stopObject Also known as: kill

Command that attempts to stop a specified process. Initially, it will check whether or not a specified process (through an option) exists. Then it will do one the following:

  1. If a process DOES exist it will send it a signal specified by the option:

    signal: the signal to be sent to processes being stopped. If none
    specified then it defaults to TERM
    
  2. If a process DOES NOT exist it it will exit with an error status of 1 (or 1 if the oknodo option is specified).

  3. If the following option is specified then start-stop-daemon will check that the process(es) have finished:

    retry: option to check whether or not process(es) finish
    


54
55
56
57
58
# File 'lib/baal/commands.rb', line 54

def stop
  @commands_and_opts.unshift COMMANDS[:stop]
  include_multiple_commands?
  self
end

#versionObject

Command that shows your program version of start-stop-daemon and then exits.



79
80
81
82
83
# File 'lib/baal/commands.rb', line 79

def version
  @commands_and_opts.unshift COMMANDS[:version]
  include_multiple_commands?
  self
end