#
# Cookbook Name:: bcpc
# Recipe:: rotate_chef_nginx_access_log
#
# Prevent chef-server's nginx access.log from filling up
# a partition
#

logrotate_app 'chef-server-nginx-access-log' do
  path '/var/log/chef-server/nginx/access.log'
  frequency 'daily'
  rotate 5
  options %w(missingok compress)
  postrotate '/usr/bin/truncate --size=0 /var/log/chef-server/nginx/access.log'
end

#
# Cookbook Name:: bcpc
# Recipe:: rotate_chef_nginx_access_log
#
# Prevent chef-server's nginx access.log from filling up
# a partition
#

logrotate_app 'chef-server-nginx-access-log' do
  path '/var/log/chef-server/nginx/access.log'
  frequency 'daily'
  rotate 5
  options %w(missingok notifempty compress delaycompress copytruncate)
  postrotate '/opt/chef-server/embedded/sbin/nginx -s reopen'
end

Fix Chef server Nginx logrotate configuration - Add `copytruncate`, `notifempty` and `delaycompress` options to ensure we get the behavior we actually want. - With `copytruncate` chosen, we can then remove the existing `postrotate` command and replace it with a `SIGUSR1`, known as a `reopen` to the Nginx daemon, which will release any open log file handles.
Fix Chef server Nginx logrotate configuration
- Add `copytruncate`, `notifempty` and `delaycompress` options to ensure
we get the behavior we actually want.
- With `copytruncate` chosen, we can then remove the existing
`postrotate` command and replace it with a `SIGUSR1`, known as a
`reopen` to the Nginx daemon, which will release any open log file
handles.
