This repository was archived by the owner on Dec 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ directory "<%= @deploy_dir %>/current"
5
5
6
6
<% if @out[:preload_app] %>
7
7
preload_app!
8
+ on_worker_boot do
9
+ next unless defined?(ActiveRecord::Base) && defined?(Rails)
10
+ next unless Gem::Requirement.new(' > = 4.1')
11
+ .satisfied_by?(Gem::Version.new(Rails.version))
12
+ ActiveRecord::Base.establish_connection
13
+ end
8
14
<% end %>
9
15
10
16
# Set the environment in which the rack's app will run. The value must be a string.
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ stderr_path "<%= @deploy_dir %>/shared/log/unicorn.stderr.log"
24
24
stdout_path "<%= @deploy_dir %> /shared/log/unicorn.stdout.log"
25
25
26
26
preload_app <%= @out [ :preload_app ] %>
27
+ <% if @out [ :preload_app ] %>
28
+ after_fork do |_server, _worker|
29
+ next unless defined?(ActiveRecord::Base) && defined?(Rails)
30
+ next unless Gem::Requirement.new('> = 4.1')
31
+ .satisfied_by?(Gem::Version.new(Rails.version))
32
+ ActiveRecord::Base.establish_connection
33
+ end
34
+ <% end %>
27
35
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
28
36
29
37
# ensure Unicorn doesn't use a stale Gemfile when restarting
You can’t perform that action at this time.
0 commit comments