class PhusionPassenger::Config::DetachProcessCommand

Private Class Methods

create_option_parser(options) click to toggle source
# File lib/phusion_passenger/config/detach_process_command.rb, line 44
def self.create_option_parser(options)
        OptionParser.new do |opts|
                nl = "\n" + ' ' * 37
                opts.banner = "Usage: passenger-config detach-process [OPTIONS] <PID>\n"
                opts.separator ""
                opts.separator "  Remove an application process from the #{PROGRAM_NAME} process pool."
                opts.separator "  Has a similar effect to killing the application process directly with"
                opts.separator "  `kill <PID>`, but killing directly may cause the HTTP client to see an"
                opts.separator "  error, while using this command guarantees that clients see no errors."
                opts.separator ""

                opts.separator "Options:"
                opts.on("--instance INSTANCE_PID", Integer, "The #{PROGRAM_NAME} instance to select") do |value|
                        options[:instance] = value
                end
                opts.on("-h", "--help", "Show this help") do
                        options[:help] = true
                end
        end
end

Public Instance Methods

run() click to toggle source
# File lib/phusion_passenger/config/detach_process_command.rb, line 36
def run
        parse_options
        select_passenger_instance
        @admin_client = connect_to_passenger_admin_socket(:role => :passenger_status)
        perform_detach
end

Private Instance Methods

help() click to toggle source
# File lib/phusion_passenger/config/detach_process_command.rb, line 65
def help
        puts @parser
end
parse_options() click to toggle source
# File lib/phusion_passenger/config/detach_process_command.rb, line 69
def parse_options
        super
        if @argv.empty?
                abort "Please pass a PID. " +
                        "See --help for more information."
        elsif @argv.size == 1
                @pid = @argv[0].to_i
        elsif @argv.size > 1
                help
                abort
        end
end
perform_detach() click to toggle source
# File lib/phusion_passenger/config/detach_process_command.rb, line 82
def perform_detach
        if @admin_client.pool_detach_process(@pid)
                puts "Process #{@pid} detached."
        else
                abort "Could not detach process #{@pid}."
        end
end