class Control_P
Constants
- FIND_BY_OPTIONS
- HOSTNAME
- OPTIONS_ATTRIBUTES
- WORKERS_CLOSED_EXTENSION
- WORKERS_STARTED_EXTENSION
Public Class Methods
do(options)
click to toggle source
Main Method for all actions
# File lib/process_controller.rb, line 19 def self.do(options) options = options.with_indifferent_access #TODO options validations action = options.fetch(OPTIONS_ATTRIBUTES[:action], nil) environment = options.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(options) when 'stop' stop_actions(options) when 'restart' restart_actions(options) 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()
click to toggle source
# File lib/process_controller.rb, line 45 def self.helper ControlHelper end
restart_actions(options)
click to toggle source
# File lib/process_controller.rb, line 49 def self.restart_actions(options) http_server = options.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!(options) sleep(5) else helper.kill_the_old_process_if_needed(options) helper.start_a_new_process!(options) end helper.check_for_success_in_starting_new_process!(options) end
start_actions(options)
click to toggle source
# File lib/process_controller.rb, line 65 def self.start_actions(options) helper.exit_if_old_process_is_already_running!(options) helper.start_a_new_process!(options) helper.check_for_success_in_starting_new_process!(options) end
stop_actions(options)
click to toggle source
# File lib/process_controller.rb, line 72 def self.stop_actions(options) helper.exit_if_not_running!(options) helper.kill_the_process!(options) end