Class: Control_P
- Inherits:
-
Object
- Object
- Control_P
- Defined in:
- lib/process_controller.rb
Constant Summary collapse
- OPTIONS_ATTRIBUTES =
{action: 'action', pid_filename: 'pid_filename', find_pid_by: 'find_pid_by', app_name: 'app_name', port_num: 'port_num', app_filename: 'app_filename', http_server: 'http_server', kill_command: 'kill_command', restart_command: 'restart_command', environment: 'environment', start_command: 'start_command', skip_workers_message: 'skip_workers_message'}.with_indifferent_access
- FIND_BY_OPTIONS =
{app_filename: 'app_filename', port_num: 'port_num', app_name: 'app_name', pid_file: 'pid_file'}.with_indifferent_access
- WORKERS_STARTED_EXTENSION =
'*.started'- WORKERS_CLOSED_EXTENSION =
'*.closed'- HOSTNAME =
Socket.gethostname
Class Method Summary collapse
-
.do(options) ⇒ Object
Main Method for all actions.
- .helper ⇒ Object
- .restart_actions(options) ⇒ Object
- .start_actions(options) ⇒ Object
- .stop_actions(options) ⇒ Object
Class Method Details
.do(options) ⇒ Object
Main Method for all actions
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/process_controller.rb', line 19 def self.do() = .with_indifferent_access #TODO options validations action = .fetch(OPTIONS_ATTRIBUTES[:action], nil) environment = .fetch(OPTIONS_ATTRIBUTES[:environment], nil) if action.nil? || environment.nil? p "didn't pass enough arguments" p 'Usage: {start|stop|restart|status} {env}, exiting' exit(1) end case action when 'start' start_actions() when 'stop' stop_actions() when 'restart' restart_actions() else raise "action #{action} not implemented" end # drom some reason the remote ssh is not exiting, making sure it exit here exit(0) end |
.helper ⇒ Object
45 46 47 |
# File 'lib/process_controller.rb', line 45 def self.helper ControlHelper end |
.restart_actions(options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/process_controller.rb', line 49 def self.restart_actions() http_server = .fetch(OPTIONS_ATTRIBUTES[:http_server], false) #means it's seamless, just need to send a kill signal and it will restart it self if http_server helper.restart_the_app!() sleep(5) else helper.kill_the_old_process_if_needed() helper.start_a_new_process!() end helper.check_for_success_in_starting_new_process!() end |
.start_actions(options) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/process_controller.rb', line 65 def self.start_actions() helper.exit_if_old_process_is_already_running!() helper.start_a_new_process!() helper.check_for_success_in_starting_new_process!() end |
.stop_actions(options) ⇒ Object
72 73 74 75 76 |
# File 'lib/process_controller.rb', line 72 def self.stop_actions() helper.exit_if_not_running!() helper.kill_the_process!() end |