Class: Baal::Daemon
- Inherits:
-
Object
- Object
- Baal::Daemon
- Includes:
- Commands, MatchingOptions, OptionalOptions
- Defined in:
- lib/baal.rb
Overview
Daemon is a builder object that allows you construct and access, at any time, the start-stop-daemon string that will be executed. All building of the start-stop-daemon string will be through this object.
A note should be made that all methods which build the start-stop-daemon script return the Daemon instance for the intention of method chaining where possible so as to read like written English.
Constant Summary collapse
- PROGRAM_NAME =
'start-stop-daemon'.freeze
Constants included from OptionalOptions
OptionalOptions::OPTIONAL_OPTS, OptionalOptions::VALID_POLICIES, OptionalOptions::VALID_SCHEDULE_CLASSES
Constants included from MatchingOptions
MatchingOptions::MATCHING_OPTIONS
Constants included from Commands
Instance Attribute Summary collapse
-
#std_status ⇒ Object
readonly
Returns the value of attribute std_status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#clear_all! ⇒ Object
Clears @commands_and_opts and starts over with only the PROGRAM_NAME.
-
#daemonize! ⇒ nil
Executes the built up start-stop-daemon string and throws an error if there isn’t at least one command and at least one matching option.
-
#execution ⇒ String
The built up, whitespace-formatted start-stop-daemon string to be executed.
-
#initialize ⇒ Daemon
constructor
A new instance of Daemon.
Methods included from OptionalOptions
#background, #chdir, #chroot, #chuid, #group, #io_sched, #make_pid_file, #nice_level, #no_close, #oknodo, #proc_sched, #quiet, #remove_pid_file, #retry, #signal, #start_as, #test, #umask, #verbose
Methods included from MatchingOptions
#exec, #name, #pid, #pid_file, #ppid, #user
Methods included from Commands
#help, #start, #status, #stop, #version
Constructor Details
#initialize ⇒ Daemon
Returns a new instance of Daemon.
40 41 42 |
# File 'lib/baal.rb', line 40 def initialize @commands_and_opts = [] end |
Instance Attribute Details
#std_status ⇒ Object (readonly)
Returns the value of attribute std_status.
38 39 40 |
# File 'lib/baal.rb', line 38 def std_status @std_status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
38 39 40 |
# File 'lib/baal.rb', line 38 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
38 39 40 |
# File 'lib/baal.rb', line 38 def stdout @stdout end |
Instance Method Details
#clear_all! ⇒ Object
Clears @commands_and_opts and starts over with only the PROGRAM_NAME
48 49 50 51 |
# File 'lib/baal.rb', line 48 def clear_all! @commands_and_opts.clear self end |
#daemonize! ⇒ nil
Executes the built up start-stop-daemon string and throws an error if there isn’t at least one command and at least one matching option.
67 68 69 70 71 72 |
# File 'lib/baal.rb', line 67 def daemonize! at_least_one_command? at_least_one_matching_option? @stdout, @stderr, @std_status = Open3.capture3(PROGRAM_NAME, *@commands_and_opts) nil end |
#execution ⇒ String
Returns the built up, whitespace-formatted start-stop-daemon string to be executed.
56 57 58 |
# File 'lib/baal.rb', line 56 def execution ([PROGRAM_NAME] + @commands_and_opts).join(' ').strip end |