From a32beb4dd0a971cbfc634300c4b61541bfbf7f4b Mon Sep 17 00:00:00 2001 From: Varik Matevosyan Date: Wed, 24 Jul 2024 17:29:39 +0400 Subject: [PATCH] run image cleanup function if disk space is low --- rhizome/lantern/bin/doctor/run_query | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rhizome/lantern/bin/doctor/run_query b/rhizome/lantern/bin/doctor/run_query index 72d69b971..24e98a817 100755 --- a/rhizome/lantern/bin/doctor/run_query +++ b/rhizome/lantern/bin/doctor/run_query @@ -94,12 +94,13 @@ SQL failed ? "t" : "f" end - def self.check_disk_space_usage(_db, _query_user) + def self.check_disk_space_usage(db, query_user) server_type = $configure_hash["server_type"] output = "" usage_percent = r("df | awk '$1 == \"/dev/root\" {print $5}' | sed 's/%//'").chomp.strip.to_i if usage_percent > 90 output += "#{server_type} server - usage #{usage_percent}%\n" + remove_dangling_images(db, query_user) end output.chomp end @@ -148,7 +149,7 @@ SQL end def self.remove_dangling_index_files(_db, _query_user) - r("sudo find /var/lib/lantern-data/data/ -name 'ldb-index*' -type f -mmin +240 -delete >/tmp/ldb-index-cleanup-logs 2>&1 && echo "" || cat /tmp/ldb-index-cleanup-logs").chomp.strip + r("sudo find /var/lib/lantern-data/data/ -name 'ldb-index*' -type f -mmin +240 -delete >/tmp/ldb-index-cleanup-logs 2>&1 && echo '' || cat /tmp/ldb-index-cleanup-logs").chomp.strip end end