PERF: Preload LetterAvatar.image_magick_version in master process.

It is wasteful to run the clean up and command to generate the version
digest on every unicorn child process.
This commit is contained in:
Alan Guo Xiang Tan 2021-05-07 13:25:31 +08:00
parent 4b7b586861
commit 4bad1e7e93

View File

@ -935,16 +935,25 @@ module Discourse
Search.prepare_data("test")
end
# router warm up
Rails.application.routes.recognize_path('abc') rescue nil
# preload discourse version
Discourse.git_version
Discourse.git_branch
Discourse.full_version
require 'actionview_precompiler'
ActionviewPrecompiler.precompile
[
Thread.new {
# router warm up
Rails.application.routes.recognize_path('abc') rescue nil
},
Thread.new {
# preload discourse version
Discourse.git_version
Discourse.git_branch
Discourse.full_version
},
Thread.new {
require 'actionview_precompiler'
ActionviewPrecompiler.precompile
},
Thread.new {
LetterAvatar.image_magick_version
}
].each(&:join)
ensure
@preloaded_rails = true
end