forked from hummypkg/webif
1
0
Fork 0

Protect log rotation operations by lock

This commit is contained in:
prpr 2023-07-12 02:25:51 +01:00
parent fb9fb6ca85
commit d22735af68
1 changed files with 8 additions and 1 deletions

View File

@ -1,13 +1,20 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require settings.class
require settings.class lock
set s [settings]
set logsize [$s logsize]
set logkeep [$s logkeep]
set logage [$s logage]
defer {catch {release_lock webif_autolog}}
if {![acquire_lock webif_autolog]} {
acquire_lock webif_autolog 10 1
puts "Could not acquire exclusive lock, terminating."
exit
}
puts "Rotating at $logsize, keeping $logkeep, max age $logage"
set logdir "/mod/tmp"