Merge branch 'unicorn_memory_restart' into 'master'

Unicorn memory restart configuration

Fixes #637

See merge request !391
This commit is contained in:
Marin Jankovski 2015-06-29 07:24:41 +00:00
commit 69e0f8f241
5 changed files with 41 additions and 0 deletions

View File

@ -65,6 +65,9 @@ build do
delete 'config/gitlab.yml'
delete 'config/database.yml'
# Remove so we can place our template
delete 'config.ru'
# Remove auto-generated files
delete '.secret'
delete '.gitlab_shell_secret'

View File

@ -248,6 +248,13 @@ external_url 'GENERATED_EXTERNAL_URL'
# We do not recommend changing this setting
# unicorn['log_directory'] = "/var/log/gitlab/unicorn"
## Only change these settings if you understand well what they mean
## see https://about.gitlab.com/2015/06/05/how-gitlab-uses-unicorn-and-unicorn-worker-killer/
## and https://github.com/kzk/unicorn-worker-killer
# unicorn['worker_memory_limit_min'] = "200*(1024**2)"
# unicorn['worker_memory_limit_max'] = "250*(1024**2)"
##################
# GitLab Sidekiq #
##################

View File

@ -195,6 +195,8 @@ default['gitlab']['unicorn']['pidfile'] = "#{node['package']['install-dir']}/var
default['gitlab']['unicorn']['tcp_nopush'] = true
default['gitlab']['unicorn']['backlog_socket'] = 1024
default['gitlab']['unicorn']['worker_timeout'] = 60
default['gitlab']['unicorn']['worker_memory_limit_min'] = "200*(1024**2)"
default['gitlab']['unicorn']['worker_memory_limit_max'] = "250*(1024**2)"
####
# Sidekiq

View File

@ -69,6 +69,16 @@ dependent_services << "service[sidekiq]" if OmnibusHelper.should_notify?("sideki
redis_not_listening = OmnibusHelper.not_listening?("redis")
postgresql_not_listening = OmnibusHelper.not_listening?("postgresql")
template_symlink File.join(gitlab_rails_etc_dir, "config.ru") do
link_from File.join(gitlab_rails_source_dir, "config.ru")
source "gitlab-rails-config.ru.erb"
owner "root"
group "root"
mode "0644"
variables(node['gitlab']['unicorn'].to_hash)
restarts dependent_services
end
template_symlink File.join(gitlab_rails_etc_dir, "secret") do
link_from File.join(gitlab_rails_source_dir, ".secret")
source "secret_token.erb"

View File

@ -0,0 +1,19 @@
# This file is used by Rack-based servers to start the application.
if defined?(Unicorn)
require 'unicorn'
if ENV['RAILS_ENV'] == 'production' || ENV['RAILS_ENV'] == 'staging'
# Unicorn self-process killer
require 'unicorn/worker_killer'
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, (<%= @worker_memory_limit_min %>), (<%= @worker_memory_limit_max %>)
end
end
require ::File.expand_path('../config/environment', __FILE__)
map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
run Gitlab::Application
end