Merge pull request #45095 from Shopify/missing-server

Improve `rails s` error message when no server could be found.
This commit is contained in:
Jean Boussier 2022-05-14 09:50:55 -04:00 committed by GitHub
commit 7d3fd6edc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -96,6 +96,7 @@ module Rails
# Hard-coding a bunch of handlers here as we don't have a public way of
# querying them from the Rack::Handler registry.
RACK_SERVERS = %w(cgi fastcgi webrick lsws scgi thin puma unicorn falcon)
RECOMMENDED_SERVER = "puma"
DEFAULT_PORT = 3000
DEFAULT_PIDFILE = "tmp/pids/server.pid"
@ -253,7 +254,15 @@ module Rails
end
def rack_server_suggestion(server)
if server.in?(RACK_SERVERS)
if server.nil?
<<~MSG
Could not find a server gem. Maybe you need to add one to the Gemfile?
gem "#{RECOMMENDED_SERVER}"
Run `bin/rails server --help` for more options.
MSG
elsif server.in?(RACK_SERVERS)
<<~MSG
Could not load server "#{server}". Maybe you need to the add it to the Gemfile?