Class: Rails::Command::ServerCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/commands/server/server_command.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_PORT =
3000
DEFAULT_PID_PATH =
"tmp/pids/server.pid".freeze

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 = {}, config = {}) ⇒ ServerCommand

Returns a new instance of ServerCommand.



132
133
134
135
136
137
# File 'lib/rails/commands/server/server_command.rb', line 132

def initialize(args = [], local_options = {}, config = {})
  @original_options = local_options
  super
  @server = self.args.shift
  @log_stdout = options[:daemon].blank? && (options[:environment] || Rails.env) == "development"
end

Instance Method Details

#performObject



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/rails/commands/server/server_command.rb', line 139

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)
    server.start
  end
end