DEV: ensure we never fork v8 contexts from unicorn

v8 forking is not supported and can lead to memory leaks.

This commit handles the most common case which is the unicorn master forking

There are still some cases related to backup where we fork, however those
forks are usually short lived so the memory leak is not severe, burning
the contexts in the master process could break sidekiq or web process that
do the actual forking
This commit is contained in:
Sam Saffron 2019-05-16 09:50:22 +10:00
parent 7cd1067f3d
commit 76173dea87
1 changed files with 3 additions and 0 deletions

View File

@ -69,6 +69,9 @@ before_fork do |server, worker|
Discourse.git_branch
Discourse.full_version
# V8 does not support forking, make sure all contexts are disposed
ObjectSpace.each_object(MiniRacer::Context) { |c| c.dispose }
# get rid of rubbish so we don't share it
GC.start