Skip to content

A platform for community discussion. Free, open, simple.

DEV: Move Discourse app specific concern out of unicorn conf.

Alan Guo Xiang Tancadf5eafe6d0
diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rb
index ffcafcb618d..b00fca1883f 100644
--- a/config/unicorn.conf.rb
+++ b/config/unicorn.conf.rb
@@ -257,14 +257,4 @@ end
after_fork do |server, worker|
DiscourseEvent.trigger(:web_fork_started)
Discourse.after_fork
-
- # warm up v8 after fork, that way we do not fork a v8 context
- # it may cause issues if bg threads in a v8 isolate randomly stop
- # working due to fork
- begin
- # Skip warmup in development mode - it makes boot take ~2s longer
- PrettyText.cook("warm up **pretty text**") if !Rails.env.development?
- rescue => e
- Rails.logger.error("Failed to warm up pretty text: #{e}")
- end
end
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 641e06fdd9a..779f8634caf 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -743,6 +743,17 @@ module Discourse
DiscourseJsProcessor::Transpiler.reset_context if defined? DiscourseJsProcessor::Transpiler
JsLocaleHelper.reset_context if defined? JsLocaleHelper
+
+ # warm up v8 after fork, that way we do not fork a v8 context
+ # it may cause issues if bg threads in a v8 isolate randomly stop
+ # working due to fork
+ begin
+ # Skip warmup in development mode - it makes boot take ~2s longer
+ PrettyText.cook("warm up **pretty text**") if !Rails.env.development?
+ rescue => e
+ Rails.logger.error("Failed to warm up pretty text: #{e}")
+ end
+
nil
end