From 95d7d9cfab757014286b85425e432a06acc80f4e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 15 Dec 2023 01:00:20 +0100 Subject: [PATCH] Implemented wait for services to stop for defroster --- .../files/system-maintenance-service-freezer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/system-maintenance-service-freezer/files/system-maintenance-service-freezer.py b/roles/system-maintenance-service-freezer/files/system-maintenance-service-freezer.py index 800e4913..2de142b4 100644 --- a/roles/system-maintenance-service-freezer/files/system-maintenance-service-freezer.py +++ b/roles/system-maintenance-service-freezer/files/system-maintenance-service-freezer.py @@ -104,6 +104,11 @@ def defrost(filtered_services): """ Defrost services by starting and enabling their timers. """ + break_time_sec = 5 + attempt = 0 + max_attempts = timeout_sec / break_time_sec + wait_for_all_services_to_stop(filtered_services, max_attempts, attempt, break_time_sec) + for service in filtered_services: print(f"Unfreezing: {service}") if service_file_exists(service, "timer"): @@ -135,7 +140,7 @@ def main(services, ignored_services, action, timeout_sec): freeze(filtered_services, timeout_sec) elif action == 'defrost': print("Unfreezing services.") - defrost(filtered_services) + defrost(filtered_services, timeout_sec) print("Overview:") subprocess.run(['systemctl', 'list-timers'])