Commit 4ff23212c78198d41c86c17c8a0dd06933d5b748
1 parent
81d759e9
Exists in
master
and in
9 other branches
Make Runit log rotation configurable
Showing
13 changed files
with
68 additions
and
11 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/attributes/default.rb
... | ... | @@ -175,8 +175,6 @@ default['gitlab']['postgresql']['ha'] = false |
175 | 175 | default['gitlab']['postgresql']['dir'] = "/var/opt/gitlab/postgresql" |
176 | 176 | default['gitlab']['postgresql']['data_dir'] = "/var/opt/gitlab/postgresql/data" |
177 | 177 | default['gitlab']['postgresql']['log_directory'] = "/var/log/gitlab/postgresql" |
178 | -default['gitlab']['postgresql']['svlogd_size'] = 1000000 | |
179 | -default['gitlab']['postgresql']['svlogd_num'] = 10 | |
180 | 178 | default['gitlab']['postgresql']['username'] = "gitlab-psql" |
181 | 179 | default['gitlab']['postgresql']['uid'] = nil |
182 | 180 | default['gitlab']['postgresql']['gid'] = nil |
... | ... | @@ -217,8 +215,6 @@ default['gitlab']['redis']['enable'] = true |
217 | 215 | default['gitlab']['redis']['ha'] = false |
218 | 216 | default['gitlab']['redis']['dir'] = "/var/opt/gitlab/redis" |
219 | 217 | default['gitlab']['redis']['log_directory'] = "/var/log/gitlab/redis" |
220 | -default['gitlab']['redis']['svlogd_size'] = 1000000 | |
221 | -default['gitlab']['redis']['svlogd_num'] = 10 | |
222 | 218 | default['gitlab']['redis']['username'] = "gitlab-redis" |
223 | 219 | default['gitlab']['redis']['uid'] = nil |
224 | 220 | default['gitlab']['redis']['gid'] = nil |
... | ... | @@ -254,3 +250,13 @@ default['gitlab']['nginx']['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqd |
254 | 250 | default['gitlab']['nginx']['ssl_ciphers'] = "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4" |
255 | 251 | default['gitlab']['nginx']['ssl_prefer_server_ciphers'] = "on" |
256 | 252 | default['gitlab']['nginx']['listen_address'] = '*' |
253 | + | |
254 | +### | |
255 | +# Logging | |
256 | +### | |
257 | +default['gitlab']['logging']['svlogd_size'] = 200 * 1024 * 1024 # rotate after 200 MB of log data | |
258 | +default['gitlab']['logging']['svlogd_num'] = 30 # keep 30 rotated log files | |
259 | +default['gitlab']['logging']['svlogd_timeout'] = 24 * 60 * 60 # rotate after 24 hours | |
260 | +default['gitlab']['logging']['svlogd_filter'] = "gzip" # compress logs with gzip | |
261 | +default['gitlab']['logging']['svlogd_udp'] = nil # transmit log messages via UDP | |
262 | +default['gitlab']['logging']['svlogd_prefix'] = nil # custom prefix for log messages | ... | ... |
files/gitlab-cookbooks/gitlab/libraries/gitlab.rb
... | ... | @@ -43,6 +43,7 @@ module Gitlab |
43 | 43 | unicorn Mash.new |
44 | 44 | sidekiq Mash.new |
45 | 45 | nginx Mash.new |
46 | + logging Mash.new | |
46 | 47 | node nil |
47 | 48 | external_url nil |
48 | 49 | git_data_dir nil |
... | ... | @@ -134,6 +135,7 @@ module Gitlab |
134 | 135 | "unicorn", |
135 | 136 | "sidekiq", |
136 | 137 | "nginx", |
138 | + "logging", | |
137 | 139 | "postgresql" |
138 | 140 | ].each do |key| |
139 | 141 | rkey = key.gsub('_', '-') | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/nginx.rb
files/gitlab-cookbooks/gitlab/recipes/postgresql.rb
... | ... | @@ -125,10 +125,9 @@ runit_service "postgresql" do |
125 | 125 | down node['gitlab']['postgresql']['ha'] |
126 | 126 | control(['t']) |
127 | 127 | options({ |
128 | - :log_directory => postgresql_log_dir, | |
129 | - :svlogd_size => node['gitlab']['postgresql']['svlogd_size'], | |
130 | - :svlogd_num => node['gitlab']['postgresql']['svlogd_num'] | |
128 | + :log_directory => postgresql_log_dir | |
131 | 129 | }.merge(params)) |
130 | + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['postgresql'].to_hash) | |
132 | 131 | end |
133 | 132 | |
134 | 133 | if node['gitlab']['bootstrap']['enable'] | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/redis.rb
... | ... | @@ -55,10 +55,9 @@ end |
55 | 55 | runit_service "redis" do |
56 | 56 | down node['gitlab']['redis']['ha'] |
57 | 57 | options({ |
58 | - :log_directory => redis_log_dir, | |
59 | - :svlogd_size => node['gitlab']['redis']['svlogd_size'], | |
60 | - :svlogd_num => node['gitlab']['redis']['svlogd_num'] | |
58 | + :log_directory => redis_log_dir | |
61 | 59 | }.merge(params)) |
60 | + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['redis'].to_hash) | |
62 | 61 | end |
63 | 62 | |
64 | 63 | if node['gitlab']['bootstrap']['enable'] | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/sidekiq.rb
... | ... | @@ -29,6 +29,7 @@ runit_service "sidekiq" do |
29 | 29 | options({ |
30 | 30 | :log_directory => sidekiq_log_dir |
31 | 31 | }.merge(params)) |
32 | + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['sidekiq'].to_hash) | |
32 | 33 | end |
33 | 34 | |
34 | 35 | if node['gitlab']['bootstrap']['enable'] | ... | ... |
files/gitlab-cookbooks/gitlab/recipes/unicorn.rb
... | ... | @@ -78,6 +78,7 @@ runit_service "unicorn" do |
78 | 78 | options({ |
79 | 79 | :log_directory => unicorn_log_dir |
80 | 80 | }.merge(params)) |
81 | + log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['unicorn'].to_hash) | |
81 | 82 | end |
82 | 83 | |
83 | 84 | if node['gitlab']['bootstrap']['enable'] | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/sv-nginx-log-config.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-postgresql-log-config.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-redis-log-config.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-sidekiq-log-config.erb
0 → 100644
files/gitlab-cookbooks/gitlab/templates/default/sv-unicorn-log-config.erb
0 → 100644
files/gitlab-cookbooks/runit/definitions/runit_service.rb
... | ... | @@ -18,7 +18,7 @@ |
18 | 18 | # limitations under the License. |
19 | 19 | # |
20 | 20 | |
21 | -define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :init_script_template => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new, :action => :enable, :down => false do | |
21 | +define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :init_script_template => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :log_options => Hash.new, :env => Hash.new, :action => :enable, :down => false do | |
22 | 22 | |
23 | 23 | include_recipe "runit" |
24 | 24 | |
... | ... | @@ -77,6 +77,24 @@ define :runit_service, :directory => nil, :only_if => false, :finish_script => f |
77 | 77 | end |
78 | 78 | end |
79 | 79 | |
80 | + template File.join(params[:options][:log_directory], "config") do | |
81 | + owner params[:owner] | |
82 | + group params[:group] | |
83 | + source "sv-#{params[:template_name]}-log-config.erb" | |
84 | + cookbook params[:cookbook] if params[:cookbook] | |
85 | + variables params[:log_options] | |
86 | + notifies :create, "ruby_block[reload #{params[:name]} svlogd configuration]" | |
87 | + end | |
88 | + | |
89 | + ruby_block "reload #{params[:name]} svlogd configuration" do | |
90 | + block do | |
91 | + File.open(File.join(sv_dir_name, "log/supervise/control"), "w") do |control| | |
92 | + control.print "h" | |
93 | + end | |
94 | + end | |
95 | + action :nothing | |
96 | + end | |
97 | + | |
80 | 98 | if params[:down] |
81 | 99 | file "#{sv_dir_name}/down" do |
82 | 100 | mode "0644" | ... | ... |