Module: Sprout::Daemon::InstanceMethods
- Defined in:
- lib/sprout/daemon.rb
Overview
Instance methods that will be available on any class that includes Sprout::Daemon.
Instance Attribute Summary (collapse)
-
- (Object) action_stack
readonly
This is the array of actions that have been provided at the class level to this instance.
-
- (Object) prompt
The prompt expression for this daemon process.
Instance Method Summary (collapse)
-
- (Object) create_outer_task(*args)
protected
This is the override of the underlying Sprout::Executable template method so that we create a 'task' instead of a 'file' task.
-
- (Object) execute
Execute the Daemon executable, followed by the collection of stored actions in the order they were called.
-
- (InstanceMethods) initialize
A new instance of InstanceMethods.
-
- (Object) system_execute(binary, params)
protected
This is the override of the underlying Sprout::Executable template method so that we create the process in a thread in order to read and write to it.
-
- (Object) update_rake_task_name_from_args(*args)
protected
This is the override of the underlying Sprout::Executable template method so that we are NOT added to the CLEAN collection.
Instance Attribute Details
- (Object) action_stack (readonly)
This is the array of actions that have been provided at the class level to this instance.
144 145 146 |
# File 'lib/sprout/daemon.rb', line 144 def action_stack @action_stack end |
- (Object) prompt
The prompt expression for this daemon process.
When executing a series of commands, the wrapper will wait until it matches this expression on stdout before continuing the series.
For FDB, this value is set like:
set :prompt, /^\(fdb\) /
Most processes can trigger a variety of different prompts, these can be expressed here using the | (or) operator.
FDB actually uses the following:
set :prompt, /^\(fdb\) |\(y or n\) /
139 140 141 |
# File 'lib/sprout/daemon.rb', line 139 def prompt @prompt end |
Instance Method Details
- (Object) create_outer_task(*args) (protected)
This is the override of the underlying Sprout::Executable template method so that we create a 'task' instead of a 'file' task.
173 174 175 176 177 |
# File 'lib/sprout/daemon.rb', line 173 def create_outer_task *args task *args do execute end end |
- (Object) execute
Execute the Daemon executable, followed by the collection of stored actions in the order they were called.
If none of the stored actions result in terminating the process, the underlying daemon will be connected to the terminal for user (manual) input.
160 161 162 163 164 165 |
# File 'lib/sprout/daemon.rb', line 160 def execute runner = super execute_actions runner handle_user_session runner Process.wait runner.pid end |
- (InstanceMethods) initialize
A new instance of InstanceMethods
146 147 148 149 |
# File 'lib/sprout/daemon.rb', line 146 def initialize super @action_stack = [] end |
- (Object) system_execute(binary, params) (protected)
This is the override of the underlying Sprout::Executable template method so that we create the process in a thread in order to read and write to it.
193 194 195 |
# File 'lib/sprout/daemon.rb', line 193 def system_execute binary, params Sprout.current_system.execute_thread binary, params end |
- (Object) update_rake_task_name_from_args(*args) (protected)
This is the override of the underlying Sprout::Executable template method so that we are NOT added to the CLEAN collection. (Work performed in the Executable)
184 185 186 |
# File 'lib/sprout/daemon.rb', line 184 def update_rake_task_name_from_args *args self.rake_task_name = parse_rake_task_arg args.last end |