Class: TTCluster::StartCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- TTCluster::StartCommand
- Defined in:
- lib/ttcluster/start_command.rb
Overview
‘start’ command implementation.
Instance Method Summary collapse
-
#initialize(runner, port) ⇒ StartCommand
constructor
Save runner and port for ‘start’ run.
-
#run ⇒ Object
Start ttcluster server.
Constructor Details
#initialize(runner, port) ⇒ StartCommand
Save runner and port for ‘start’ run.
17 18 19 20 |
# File 'lib/ttcluster/start_command.rb', line 17 def initialize(runner, port) super(runner) @port = port end |
Instance Method Details
#run ⇒ Object
Start ttcluster server.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ttcluster/start_command.rb', line 24 def run chdir_to_ttbase statuses = get_statuses(@port) puts "TTCluster Start:" statuses.each do |port, status| msg = case status when /^running pid\((\d+)\)/ MSG_SERVER_ALREADY_RUNNING % $1 when /^mismatch pid\((\d+)\)/ pid = $1 remove_pid_file(port) if stop_server(pid.to_i) pid = start_server(port) pid>0 ? (MSG_STARTED_SERVER % pid) : MSG_FAILED_TO_START_SERVER else MSG_FAILED_TO_STOP_MISMATCH_SERVER % pid end when /^not running/ pid = start_server(port) pid>0 ? (MSG_STARTED_SERVER % pid) : MSG_FAILED_TO_START_SERVER when /^stale pid\((\d+)\)/ remove_pid_file(port) pid = start_server(port) pid>0 ? (MSG_STARTED_SERVER % pid) : MSG_FAILED_TO_START_SERVER end puts " port(#{port}) => #{msg}" end end |