X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/59899933a1b22ff9e35a50730ea5eebf9dcfc6a6..c5bea9b23b86f421342a1a0c9c8de98acc250304:/cookbooks/tile/templates/default/cleanup-tiles.erb diff --git a/cookbooks/tile/templates/default/cleanup-tiles.erb b/cookbooks/tile/templates/default/cleanup-tiles.erb index c4bff4cce..eebcd41a4 100644 --- a/cookbooks/tile/templates/default/cleanup-tiles.erb +++ b/cookbooks/tile/templates/default/cleanup-tiles.erb @@ -7,8 +7,14 @@ use warnings; use File::Temp qw(tmpnam); use Filesys::Df; +use LockFile::Simple; my $tiledir = shift @ARGV; + +my $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1, -hold => 0, -warn => 0); + +$lockmgr->lock("${tiledir}/cleanup") || exit 0; + my $tempfile = tmpnam(); if (df($tiledir)->{per} > 90) @@ -45,4 +51,6 @@ if (df($tiledir)->{per} > 90) unlink($tempfile); +$lockmgr->unlock("${tiledir}/cleanup"); + exit 0;