This commit is contained in:
VS
2026-09-25 12:21:47 +02:00
parent d4a5bc5476
commit f17ff1e98a
+9 -3
View File
@@ -10,7 +10,8 @@ from retinaface import RetinaFace
treashold = float(os.getenv('FACE_TRASHOLD', '0.9')) treashold = float(os.getenv('FACE_TRASHOLD', '0.9'))
sever = os.getenv('API_ROOT', 'localhost:8000') sever = os.getenv('API_ROOT', 'localhost:8000')
disk_treashold = os.getenv('DISK_FREE_TRASHOLD', 10) disk_treashold = float(os.getenv('DISK_FREE_TRASHOLD', '10.0'))
disk_treashold_gb = float(os.getenv('DISK_FREE_TRASHOLD_GB', '20.0'))
root_api_url = 'http://{}/local'.format(sever) root_api_url = 'http://{}/local'.format(sever)
base_path = '/app/data/' base_path = '/app/data/'
@@ -18,6 +19,7 @@ base_path = '/app/data/'
print("API_ROOT: " + str(root_api_url), flush=True) print("API_ROOT: " + str(root_api_url), flush=True)
print("FACE_TRASHOLD: " + str(treashold), flush=True) print("FACE_TRASHOLD: " + str(treashold), flush=True)
print("DISK_FREE_TRASHOLD: " + str(disk_treashold), flush=True) print("DISK_FREE_TRASHOLD: " + str(disk_treashold), flush=True)
print("DISK_FREE_TRASHOLD_GB: " + str(disk_treashold_gb), flush=True)
try: try:
while True: while True:
@@ -26,10 +28,14 @@ try:
#Chesk if there is enought free space at destination path #Chesk if there is enought free space at destination path
while True: while True:
total, used, free = shutil.disk_usage(base_path) total, used, free = shutil.disk_usage(base_path)
if (free // (2**30)) > ((total / 100) * disk_treashold) // (2**30): free_gb = free / (2**30)
below_percent = free < (total / 100) * disk_treashold
not_above_gb = free_gb <= disk_treashold_gb
# Not enough space only if free space is below the % threshold AND not above the GB threshold
if not (below_percent and not_above_gb):
break break
data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "%"} data = {"trace": "not enought free space at destination" + str(base_path) + " trashold is: " + str(disk_treashold) + "% and " + str(disk_treashold_gb) + " GB"}
response = requests.post('{}/log'.format(root_api_url), json=data) response = requests.post('{}/log'.format(root_api_url), json=data)
print("sleep", flush=True) print("sleep", flush=True)