Class: Rails::Server

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

Defined Under Namespace

Classes: Options

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Server

Returns a new instance of Server.



19
20
21
22
23
# File 'lib/rails/commands/server/server_command.rb', line 19

def initialize(options = nil)
  @default_options = options || {}
  super(@default_options)
  set_environment
end

Instance Method Details

#default_optionsObject



55
56
57
# File 'lib/rails/commands/server/server_command.rb', line 55

def default_options
  super.merge(@default_options)
end

#middlewareObject



51
52
53
# File 'lib/rails/commands/server/server_command.rb', line 51

def middleware
  Hash.new([])
end

#opt_parserObject



25
26
27
# File 'lib/rails/commands/server/server_command.rb', line 25

def opt_parser
  Options.new
end

#serveable?Boolean

:nodoc:

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/rails/commands/server/server_command.rb', line 44

def serveable? # :nodoc:
  server
  true
rescue LoadError, NameError
  false
end

#served_urlObject



59
60
61
# File 'lib/rails/commands/server/server_command.rb', line 59

def served_url
  "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}" unless use_puma?
end

#set_environmentObject



29
30
31
# File 'lib/rails/commands/server/server_command.rb', line 29

def set_environment
  ENV["RAILS_ENV"] ||= options[:environment]
end

#start(after_stop_callback = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/rails/commands/server/server_command.rb', line 33

def start(after_stop_callback = nil)
  trap(:INT) { exit }
  create_tmp_directories
  setup_dev_caching
  log_to_stdout if options[:log_stdout]

  super()
ensure
  after_stop_callback.call if after_stop_callback
end