Class: PhusionPassenger::Standalone::StopCommand

Inherits:
Command show all
Defined in:
lib/phusion_passenger/standalone/stop_command.rb

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#initialize, show_in_command_list

Constructor Details

This class inherits a constructor from PhusionPassenger::Standalone::Command

Class Method Details

.descriptionObject



29
30
31
# File 'lib/phusion_passenger/standalone/stop_command.rb', line 29

def self.description
	return "Stop a running Phusion Passenger Standalone instance."
end

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/phusion_passenger/standalone/stop_command.rb', line 33

def run
	parse_options!("stop") do |opts|
		opts.on("-p", "--port NUMBER", Integer,
			wrap_desc("The port number of a Phusion Passenger Standalone instance (default: #{@options[:port]})")) do |value|
			@options[:port] = value
		end
		opts.on("--pid-file FILE", String,
			wrap_desc("PID file of a running Phusion Passenger Standalone instance.")) do |value|
			@options[:pid_file] = value
		end
	end
	
	determine_various_resource_locations(false)
	create_nginx_controller
	begin
		running = @nginx.running?
	rescue SystemCallError, IOError
		running = false
	end
	if running
		@nginx.stop
	else
		STDERR.puts "According to the PID file '#{@options[:pid_file]}', " <<
			"Phusion Passenger Standalone doesn't seem to be running."
		STDERR.puts
		STDERR.puts "If you know that Phusion Passenger Standalone *is* running then one of these"
		STDERR.puts "might be the cause of this error:"
		STDERR.puts
		STDERR.puts " * The Phusion Passenger Standalone instance that you want to stop isn't running"
		STDERR.puts "   on port #{@options[:port]}, but on another port. If this is the case then you"
		STDERR.puts "   should specify the right port with --port."
		STDERR.puts "   If the instance is listening on a Unix socket file instead of a TCP port,"
		STDERR.puts "   then please specify the PID file's filename with --pid-file."
		STDERR.puts " * The instance that you want to stop has stored its PID file in a non-standard"
		STDERR.puts "   location. In this case please specify the right PID file with --pid-file."
		exit 1
	end
end