Class: TTCluster::StopCommand

Inherits:
BaseCommand show all
Defined in:
lib/ttcluster/stop_command.rb

Overview

‘stop’ command implementation.

Instance Method Summary collapse

Constructor Details

#initialize(runner, port) ⇒ StopCommand

Save runner and port for ‘stop’ run.



17
18
19
20
# File 'lib/ttcluster/stop_command.rb', line 17

def initialize(runner, port)
  super(runner)
  @port = port
end

Instance Method Details

#runObject

Stop ttcluster server.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ttcluster/stop_command.rb', line 24

def run
  chdir_to_ttbase

  statuses = get_statuses(@port)

  puts "TTCluster Stop:"
  statuses.each do |port, status|
    msg =
    case status
    when /^(running|mismatch) pid\((\d+)\)/
      (stop_server($2.to_i) ? MSG_STOPPED_SERVER : MSG_FAILED_TO_STOP_SERVER) % $2
    when /^not running/
      MSG_SERVER_NOT_RUNNING
    when /^stale pid\((\d+)\)/
      remove_pid_file(port)
      MSG_STALE_PID % $1
    end

    puts "  port(#{port}) => #{msg}"
  end
end