20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rider_server/services/rails.rb', line 20
def start(stream_id)
@stream_id = stream_id
eval('::APP_PATH = File.expand_path("./config/application", Dir.pwd)', TOPLEVEL_BINDING, __FILE__, __LINE__)
nputs "Starting Rails Server..."
@thread = Thread.new do
require File.expand_path("./config/boot", Dir.pwd)
require "rails/command"
require "rails/commands/server/server_command"
set_application_directory!
::Rails::Server.new(server_options).tap do |server|
require APP_PATH
Dir.chdir(::Rails.application.root)
unless Rails.application.config.middleware.include?(Services::RailsExceptionMiddleware)
::Rails.application.config.middleware.insert_after(
ActionDispatch::DebugExceptions, Services::RailsExceptionMiddleware, @stream_id, @session
)
end
if server.serveable?
nputs_boot_information(server.server, server.served_url)
after_stop_callback = -> { nputs "Rails Server Exiting..." }
server.start(after_stop_callback)
else
nputs rack_server_suggestion(options[:using])
end
end
rescue => e
@session.add_exception(stream_id, e)
nputs "Error starting Rails Server: #{e.message}"
end
end
|