Class: Rails::Command::ServerCommand

Inherits:
Base
  • Object
show all
Includes:
EnvironmentArgument
Defined in:
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)
DEFAULT_PORT =
3000
DEFAULT_PIDFILE =
"tmp/pids/server.pid"

Instance Method Summary collapse

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.



123
124
125
126
127
# File 'lib/rails/commands/server/server_command.rb', line 123

def initialize(args, local_options, *)
  super

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

Instance Method Details

#performObject



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

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(options[:using])
    end
  end
end