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