DEV: Update server startup warning to be more specific (#12949)

Using `bundle exec` will slow down server startup by at least 0.5s. `bin/unicorn` has built-in handling of bundler dependencies, so it is better to launch `bin/rails s` or `bin/unicorn` directly.
This commit is contained in:
David Taylor 2021-05-05 13:33:11 +01:00 committed by GitHub
parent 2024440c94
commit ac1d344368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View File

@ -10,17 +10,6 @@ if !ENV["RAILS_ENV"] && (ARGV[0] == "s" || ARGV[0] == "server")
ENV["RAILS_LOGS_STDOUT"] ||= "1" ENV["RAILS_LOGS_STDOUT"] ||= "1"
STDERR.puts <<~MESSAGE
--------
WARNING: Discourse uses `bin/unicorn` to start the web server.
For backwards compatibility, `rails s` will do this automatically.
For improved performance you should run `bin/unicorn` directly.
Running:
UNICORN_PORT=#{ENV["UNICORN_PORT"]} RAILS_LOGS_STDOUT=#{ENV["RAILS_LOGS_STDOUT"]} bin/unicorn
--------
MESSAGE
exec File.expand_path("unicorn", __dir__) exec File.expand_path("unicorn", __dir__)
end end

View File

@ -6,6 +6,12 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath) Pathname.new(__FILE__).realpath)
RAILS_ROOT = File.expand_path("../../", Pathname.new(__FILE__).realpath) RAILS_ROOT = File.expand_path("../../", Pathname.new(__FILE__).realpath)
if defined? Bundler
STDERR.puts <<~MESSAGE
WARNING: Using `bundle exec` to start the server is unnecessary, and will make startup slower. Use `bin/rails s` or `bin/unicorn`.
MESSAGE
end
require 'rubygems' require 'rubygems'
require 'bundler/setup' require 'bundler/setup'
require 'digest' require 'digest'