Class: Rails::Command::ServerCommand

Inherits:
Base show all
Includes:
EnvironmentArgument
Defined in:
railties/lib/rails/commands/server/server_command.rb

Overview

:nodoc:

Constant Summary collapse

RACK_SERVERS =

Hard-coding a bunch of handlers here as we don’t have a public way of querying them from the Rack::Handler registry.

%w(cgi fastcgi webrick lsws scgi thin puma unicorn falcon)
"puma"
DEFAULT_PORT =
3000
DEFAULT_PIDFILE =
"tmp/pids/server.pid"

Instance Method Summary collapse

Methods inherited from Base

banner, base_name, class_usage, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, help, hide_command!, inherited, namespace, perform, printing_commands, usage_path

Methods included from Actions

#boot_application!, #load_environment_config!, #load_generators, #load_tasks, #require_application!, #set_application_directory!

Constructor Details

#initialize(args, local_options) ⇒ ServerCommand

Returns a new instance of ServerCommand.



125
126
127
128
129
# File 'railties/lib/rails/commands/server/server_command.rb', line 125

def initialize(args, local_options, *)
  super

  @original_options = local_options - %w( --restart )
end

Instance Method Details

#performObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'railties/lib/rails/commands/server/server_command.rb', line 132

def perform
  set_application_directory!
  prepare_restart

  Rails::Server.new(server_options).tap do |server|
    # Require application after server sets environment to propagate
    # the --environment option.
    require APP_PATH
    Dir.chdir(Rails.application.root)

    if server.serveable?
      print_boot_information(server.server, server.served_url)
      after_stop_callback = -> { say "Exiting" unless options[:daemon] }
      server.start(after_stop_callback)
    else
      say rack_server_suggestion(options[:using])
    end
  end
end