Commit 2838abd63378b3b546ec63248505a6c81db88332
Exists in
master
and in
9 other branches
Merge branch 'runit_log_settings' into 'master'
Make Runit log rotation configurable
Showing
15 changed files
with
110 additions
and
11 deletions
Show diff stats
CHANGELOG
... | ... | @@ -17,6 +17,8 @@ omnibus-gitlab repository. |
17 | 17 | - Include Python and docutils for reStructuredText support |
18 | 18 | - Update Ruby to version 2.1.1 |
19 | 19 | - Update Git to version 2.0.0 |
20 | +- Make Runit log rotation configurable | |
21 | +- Change default Runit log rotation from 10x1MB to 30x24h | |
20 | 22 | |
21 | 23 | 6.9.2 |
22 | 24 | - Create the authorized-keys.lock file for gitlab-shell 1.9.4 | ... | ... |
README.md
... | ... | @@ -455,6 +455,45 @@ Omnibus-gitlab uses four different directories. |
455 | 455 | - `/var/log/gitlab` contains all log data generated by components of |
456 | 456 | omnibus-gitlab. |
457 | 457 | |
458 | +## Logs | |
459 | + | |
460 | +### Tail logs in a console on the server | |
461 | + | |
462 | +If you want to 'tail', i.e. view live log updates of GitLab logs you can use | |
463 | +`gitlab-ctl tail`. | |
464 | + | |
465 | +```shell | |
466 | +# Tail all logs; press Ctrl-C to exit | |
467 | +sudo gitlab-ctl tail | |
468 | + | |
469 | +# Drill down to a sub-directory of /var/log/gitlab | |
470 | +sudo gitlab-ctl tail gitlab-rails | |
471 | + | |
472 | +# Drill down to an individual file | |
473 | +sudo gitlab-ctl tail nginx/gitlab_error.log | |
474 | +``` | |
475 | + | |
476 | +### Runit logs | |
477 | + | |
478 | +The Runit-managed services in omnibus-gitlab generate log data using | |
479 | +[svlogd][svlogd]. See the [svlogd documentation][svlogd] for more information | |
480 | +about the files it generates. | |
481 | + | |
482 | +You can modify svlogd settings via `/etc/gitlab/gitlab.rb` with the following settings: | |
483 | + | |
484 | +```ruby | |
485 | +# Below are the default values | |
486 | +logging['svlogd_size'] = 200 * 1024 * 1024 # rotate after 200 MB of log data | |
487 | +logging['svlogd_num'] = 30 # keep 30 rotated log files | |
488 | +logging['svlogd_timeout'] = 24 * 60 * 60 # rotate after 24 hours | |
489 | +logging['svlogd_filter'] = "gzip" # compress logs with gzip | |
490 | +logging['svlogd_udp'] = nil # transmit log messages via UDP | |
491 | +logging['svlogd_prefix'] = nil # custom prefix for log messages | |
492 | + | |
493 | +# Optionally, you can override the prefix for e.g. Nginx | |
494 | +nginx['svlogd_prefix'] = "nginx" | |
495 | +``` | |
496 | + | |
458 | 497 | ## Starting a Rails console session |
459 | 498 | |
460 | 499 | If you need access to a Rails production console for your GitLab installation |
... | ... | @@ -543,3 +582,4 @@ This omnibus installer project is based on the awesome work done by Chef in |
543 | 582 | [database.yml.postgresql]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/database.yml.postgresql |
544 | 583 | [database.yml.mysql]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/database.yml.mysql |
545 | 584 | [gitlab.yml.example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/gitlab.yml.example |
585 | +[svlogd]: http://smarden.org/runit/svlogd.8.html | ... | ... |
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" | ... | ... |