Class: Fate::Control
- Inherits:
-
Object
- Object
- Fate::Control
- Includes:
- Harp
- Defined in:
- lib/fate.rb,
lib/fate/repl.rb
Instance Attribute Summary collapse
-
#completions ⇒ Object
readonly
Returns the value of attribute completions.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
-
#initialize(manager, options = {}) ⇒ Control
constructor
A new instance of Control.
- #log(*args, &block) ⇒ Object
- #restart(*command_strings) ⇒ Object
-
#run(*command_strings) ⇒ Object
Run only the processes specified by the arguments.
- #running ⇒ Object
- #start(*command_strings) ⇒ Object
- #stop(*command_strings) ⇒ Object
-
#system(command) ⇒ Object
ad hoc shell out, with rescuing because of some apparent bugs in MRI 1.8.7’s ability to cope with unusual exit codes.
Constructor Details
#initialize(manager, options = {}) ⇒ Control
Returns a new instance of Control.
27 28 29 30 31 32 33 34 |
# File 'lib/fate.rb', line 27 def initialize(manager, ={}) @manager = manager @service = @manager.service @completions = @service.completions @spec = @service.specification @logger = @service.logger["Fate Control"] end |
Instance Attribute Details
#completions ⇒ Object (readonly)
Returns the value of attribute completions.
25 26 27 |
# File 'lib/fate.rb', line 25 def completions @completions end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
25 26 27 |
# File 'lib/fate.rb', line 25 def logger @logger end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
25 26 27 |
# File 'lib/fate.rb', line 25 def manager @manager end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
25 26 27 |
# File 'lib/fate.rb', line 25 def service @service end |
Instance Method Details
#log(*args, &block) ⇒ Object
36 37 38 |
# File 'lib/fate.rb', line 36 def log(*args, &block) @logger.log(*args, &block) end |
#restart(*command_strings) ⇒ Object
52 53 54 55 |
# File 'lib/fate.rb', line 52 def restart(*command_strings) stop(*command_strings) start(*command_strings) end |
#run(*command_strings) ⇒ Object
Run only the processes specified by the arguments. Any existing processes outside this set will be stopped.
59 60 61 |
# File 'lib/fate.rb', line 59 def run(*command_strings) manager.run(command_strings) end |
#running ⇒ Object
63 64 65 |
# File 'lib/fate.rb', line 63 def running manager.running end |
#start(*command_strings) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/fate.rb', line 40 def start(*command_strings) if manager.start(command_strings) logger.green "All processes are running." else logger.error "Failed to start." end end |
#stop(*command_strings) ⇒ Object
48 49 50 |
# File 'lib/fate.rb', line 48 def stop(*command_strings) manager.stop(command_strings) end |
#system(command) ⇒ Object
ad hoc shell out, with rescuing because of some apparent bugs in MRI 1.8.7’s ability to cope with unusual exit codes.
69 70 71 72 73 74 75 |
# File 'lib/fate.rb', line 69 def system(command) begin Kernel.system command rescue => error puts "Exception raised when executing '#{command}': #{error.inspect}" end end |