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)
DEFAULT_PORT =
3000
DEFAULT_PIDFILE =
"tmp/pids/server.pid"

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included

Methods inherited from Base

base_name, 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

#load_generators, #load_tasks, #require_application!, #require_application_and_environment!, #require_environment!, #set_application_directory!

Constructor Details

#initialize(args, local_options) ⇒ ServerCommand

Returns a new instance of ServerCommand.



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

def initialize(args, local_options, *)
  super

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

Instance Method Details

#performObject



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

def perform
  extract_environment_option_from_argument
  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(using)
    end
  end
end