X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/d0f0b0a69917048f0340ca8acbca2e6be345522e..73a67339250bfe5c89820ed34e84329cc42e346c:/cookbooks/tile/templates/default/cleanup-tiles.erb?ds=sidebyside diff --git a/cookbooks/tile/templates/default/cleanup-tiles.erb b/cookbooks/tile/templates/default/cleanup-tiles.erb index 8a2c062be..b0a6a7419 100644 --- a/cookbooks/tile/templates/default/cleanup-tiles.erb +++ b/cookbooks/tile/templates/default/cleanup-tiles.erb @@ -7,13 +7,19 @@ 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) { - system("find", $tiledir, "-xdev", "-type", "f", "-name", "*.meta", "-atime", "+28", "-fprintf", $tempfile, "%A@ %p\n"); + system("find", $tiledir, "-xdev", "-name", "lost+found", "-prune", "-o", "-type", "f", "-name", "*.meta", "-atime", "+10", "-fprintf", $tempfile, "%A@ %p\n"); open(TILES, "-|", "sort", "-n", $tempfile) || die "Can't open $tempfile: $!"; @@ -45,4 +51,6 @@ if (df($tiledir)->{per} > 90) unlink($tempfile); +$lockmgr->unlock("${tiledir}/cleanup"); + exit 0;