Improved shutting down

This commit is contained in:
Chris Josten 2021-01-02 15:38:46 +01:00
parent 6f8da01075
commit ceb06abce6

View file

@ -5,6 +5,7 @@ import asyncio
import logging
import os
import signal
import sys
import subprocess
import time
@ -54,7 +55,8 @@ def trusty_sleep(amount: float):
def sigterm_handler(signum, frame):
LOGGER.debug("Notifying of shutdown")
client.notify("NotifyShutdown")
prepareShutdown()
sys.exit(0)
def sigusr1_handler(signum, frame):
LOGGER.debug("Going to sleep")
@ -66,6 +68,8 @@ def sigusr2_handler(signum, frame):
if client:
client.notify("NotifyWakeup")
def prepareShutdown():
client.notify("NotifyShutdown")
def main() -> None:
global TIMEOUT
@ -107,7 +111,7 @@ def main() -> None:
last_checked_value = True
else:
last_checked_value = False
sigterm_handler()
prepareShutdown()
os.system("shutdown +1 The system is going to shut down because no active sessions were found and no one is on the server")