Module: Cognizant::Process::Actions::Start
- Included in:
- Cognizant::Process::Actions
- Defined in:
- lib/cognizant/process/actions/start.rb
Instance Attribute Summary collapse
-
#start_after_command ⇒ String
The command to run after the process is started.
-
#start_before_command ⇒ String
The command to run before the process is started.
-
#start_command ⇒ String
The command to start the process with.
-
#start_env ⇒ Hash
Environment variables for process during start.
-
#start_timeout ⇒ String
The grace time period in seconds for the process to start within.
-
#start_with_input ⇒ String
Start the process with this in it’s STDIN.
-
#start_with_input_command ⇒ String
Start the process with this command’s output in it’s (process’) STDIN.
-
#start_with_input_file ⇒ String
Start the process with this file’s data in it’s STDIN.
Instance Method Summary collapse
- #_start_result_handler(result, time_left = 0) ⇒ Object
- #reset_attributes! ⇒ Object
- #start_process ⇒ Object
Instance Attribute Details
#start_after_command ⇒ String
The command to run after the process is started.
43 44 45 |
# File 'lib/cognizant/process/actions/start.rb', line 43 def start_after_command @start_after_command end |
#start_before_command ⇒ String
The command to run before the process is started. The exit status of this command determines whether or not to proceed.
12 13 14 |
# File 'lib/cognizant/process/actions/start.rb', line 12 def start_before_command @start_before_command end |
#start_command ⇒ String
The command to start the process with. e.g. “/usr/bin/redis-server”
17 18 19 |
# File 'lib/cognizant/process/actions/start.rb', line 17 def start_command @start_command end |
#start_env ⇒ Hash
Environment variables for process during start.
7 8 9 |
# File 'lib/cognizant/process/actions/start.rb', line 7 def start_env @start_env end |
#start_timeout ⇒ String
The grace time period in seconds for the process to start within. Covers the time period for the input and start command. After the timeout is over, the process is considered as not started and it re-enters the auto start lifecycle based on conditions.
39 40 41 |
# File 'lib/cognizant/process/actions/start.rb', line 39 def start_timeout @start_timeout end |
#start_with_input ⇒ String
Start the process with this in it’s STDIN. e.g. “daemonize no”
22 23 24 |
# File 'lib/cognizant/process/actions/start.rb', line 22 def start_with_input @start_with_input end |
#start_with_input_command ⇒ String
Start the process with this command’s output in it’s (process’) STDIN. e.g. “cat /etc/redis/redis.conf”
32 33 34 |
# File 'lib/cognizant/process/actions/start.rb', line 32 def start_with_input_command @start_with_input_command end |
#start_with_input_file ⇒ String
Start the process with this file’s data in it’s STDIN. e.g. “/etc/redis/redis.conf”
27 28 29 |
# File 'lib/cognizant/process/actions/start.rb', line 27 def start_with_input_file @start_with_input_file end |
Instance Method Details
#_start_result_handler(result, time_left = 0) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cognizant/process/actions/start.rb', line 79 def _start_result_handler(result, time_left = 0) if result.respond_to?(:succeeded?) and result.succeeded? write_pid(result.pid) if self.daemonize and result.pid != 0 end # Reset cached pid to read from file or command. @process_pid = nil # Rollback the pending skips. skip_ticks_for(-time_left) if time_left > 0 end |
#reset_attributes! ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cognizant/process/actions/start.rb', line 45 def reset_attributes! self.start_env = {} self.start_before_command = nil self.start_command = nil self.start_with_input = nil self.start_with_input_file = nil self.start_with_input_command = nil self.start_timeout = 30 self.start_after_command = nil super end |
#start_process ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cognizant/process/actions/start.rb', line 57 def start_process # We skip so that we're not reinformed about the required transition by the tick. skip_ticks_for(self.start_timeout) = { name: self.name, daemonize: self.daemonize, env: self.env.merge(self.start_env), logfile: self.logfile, errfile: self.errfile, before: self.start_before_command, command: self.start_command, input: self.start_with_input, input_file: self.start_with_input_file, input_command: self.start_with_input_command, after: self.start_after_command, timeout: self.start_timeout } handle_action('_start_result_handler', ) end |