]> git.openstreetmap.org Git - chef.git/commitdiff
Use a lock file to stop multiple tile expirys running at once
authorTom Hughes <tom@compton.nu>
Fri, 4 Oct 2013 19:16:14 +0000 (20:16 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 4 Oct 2013 19:40:50 +0000 (20:40 +0100)
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/cleanup-tiles.erb

index d2f875611e6a9630890b820d3e3f3822ab14f384..b80dc01fb53c9793ae384abaa5af5b0076813562 100644 (file)
@@ -488,6 +488,7 @@ template "/etc/rsyslog.d/20-renderd.conf" do
   notifies :restart, "service[rsyslog]"
 end
 
+package "liblockfile-simple-perl"
 package "libfilesys-df-perl"
 
 template "/usr/local/bin/cleanup-tiles" do
index c4bff4cce3d1f00da308a8287a0d81361fe6908b..9209a2644d8116663b16cbfc60b951ba52981625 100644 (file)
@@ -7,8 +7,12 @@ use warnings;
 
 use File::Temp qw(tmpnam);
 use Filesys::Df;
+use LockFile::Simple qw(lock unlock);
 
 my $tiledir = shift @ARGV;
+
+lock($tiledir) || exit 0;
+
 my $tempfile = tmpnam();
 
 if (df($tiledir)->{per} > 90)
@@ -45,4 +49,6 @@ if (df($tiledir)->{per} > 90)
 
 unlink($tempfile);
 
+unlock($tiledir);
+
 exit 0;