Implemented wait for services to stop for defroster

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-15 01:00:20 +01:00
parent 9116a2fa00
commit 95d7d9cfab

View File

@ -104,6 +104,11 @@ def defrost(filtered_services):
""" """
Defrost services by starting and enabling their timers. 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: for service in filtered_services:
print(f"Unfreezing: {service}") print(f"Unfreezing: {service}")
if service_file_exists(service, "timer"): if service_file_exists(service, "timer"):
@ -135,7 +140,7 @@ def main(services, ignored_services, action, timeout_sec):
freeze(filtered_services, timeout_sec) freeze(filtered_services, timeout_sec)
elif action == 'defrost': elif action == 'defrost':
print("Unfreezing services.") print("Unfreezing services.")
defrost(filtered_services) defrost(filtered_services, timeout_sec)
print("Overview:") print("Overview:")
subprocess.run(['systemctl', 'list-timers']) subprocess.run(['systemctl', 'list-timers'])