Reduce number of nginx logs kept on tile caches
authorTom Hughes <tom@compton.nu>
Wed, 11 May 2016 21:23:16 +0000 (22:23 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 11 May 2016 21:23:16 +0000 (22:23 +0100)
cookbooks/tilecache/recipes/default.rb
cookbooks/tilecache/templates/default/logrotate.nginx.erb [new file with mode: 0644]

index 1f02661b7e912a1b564c8ed37338d06465703f07..86c7d0250d14b7cc7c6346a34c2f3681973212d3 100644 (file)
@@ -101,6 +101,13 @@ service "nginx-certificate-restart" do
   subscribes :restart, "file[/etc/ssl/private/#{certificate}.key]"
 end
 
+template "/etc/logrotate.d/nginx" do
+  source "logrotate.nginx.erb"
+  owner "root"
+  group "root"
+  mode 0644
+end
+
 tilerenders.each do |render|
   munin_plugin "ping_#{render[:fqdn]}" do
     target "ping_"
diff --git a/cookbooks/tilecache/templates/default/logrotate.nginx.erb b/cookbooks/tilecache/templates/default/logrotate.nginx.erb
new file mode 100644 (file)
index 0000000..b52d294
--- /dev/null
@@ -0,0 +1,15 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+/var/log/nginx/*.log {
+  daily
+  missingok
+  rotate 7
+  compress
+  delaycompress
+  notifempty
+  create 640 nginx adm
+  sharedscripts
+  postrotate
+    [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
+  endscript
+}