diff options
author | Stan Hu <stanhu@gmail.com> | 2018-08-03 11:20:08 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-08-03 11:20:08 +0000 |
commit | 4b9f2bab73b753c1efbf148e44bd03ec4af90d14 (patch) | |
tree | d849c8c50de1ea86b5679fbb3f26f9d7fc5a7d1a /config | |
parent | b901df220c9411eba4f541ac91b3e275a0dfa1df (diff) | |
parent | e315dca6ceb5528a9b2c0f6d76261281a61a65b9 (diff) | |
download | gitlab-ce-4b9f2bab73b753c1efbf148e44bd03ec4af90d14.tar.gz |
Merge branch '49756-update-unicorn.rb.example.development' into 'master'
Resolve "Unicorn development settings should match production as much as possible"
Closes #49756
See merge request gitlab-org/gitlab-ce!20919
Diffstat (limited to 'config')
-rw-r--r-- | config/unicorn.rb.example | 8 | ||||
-rw-r--r-- | config/unicorn.rb.example.development | 17 |
2 files changed, 21 insertions, 4 deletions
diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example index 8f2d842e5b6..020e9a00d87 100644 --- a/config/unicorn.rb.example +++ b/config/unicorn.rb.example @@ -67,11 +67,11 @@ pid "/home/git/gitlab/tmp/pids/unicorn.pid" stderr_path "/home/git/gitlab/log/unicorn.stderr.log" stdout_path "/home/git/gitlab/log/unicorn.stdout.log" -# combine Ruby 2.0.0dev or REE with "preload_app true" for memory savings -# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow +# Save memory by sharing the application code among multiple Unicorn workers +# with "preload_app true". See: +# https://www.rubydoc.info/gems/unicorn/5.1.0/Unicorn%2FConfigurator:preload_app +# https://brandur.org/ruby-memory#copy-on-write preload_app true -GC.respond_to?(:copy_on_write_friendly=) and - GC.copy_on_write_friendly = true # Enable this flag to have unicorn test client connections by writing the # beginning of the HTTP headers before calling the application. This diff --git a/config/unicorn.rb.example.development b/config/unicorn.rb.example.development index 0df028648d1..5712549a66d 100644 --- a/config/unicorn.rb.example.development +++ b/config/unicorn.rb.example.development @@ -1,7 +1,15 @@ worker_processes 2 timeout 60 +preload_app true +check_client_connection false + before_fork do |server, worker| + # the following is highly recommended for Rails + "preload_app true" + # as there's no need for the master process to hold a connection + defined?(ActiveRecord::Base) and + ActiveRecord::Base.connection.disconnect! + if /darwin/ =~ RUBY_PLATFORM require 'fiddle' @@ -13,3 +21,12 @@ before_fork do |server, worker| end end +after_fork do |server, worker| + # Unicorn clears out signals before it forks, so rbtrace won't work + # unless it is enabled after the fork. + require 'rbtrace' if ENV['ENABLE_RBTRACE'] + + # the following is *required* for Rails + "preload_app true", + defined?(ActiveRecord::Base) and + ActiveRecord::Base.establish_connection +end |