added keyboard interupt handling

This commit is contained in:
2026-04-17 02:21:35 +05:30
parent c4dd0a138c
commit ac931feb47

View File

@@ -28,6 +28,7 @@ ntfy_token = os.environ['NTFY_Token']
device_name = os.environ['device_name'] device_name = os.environ['device_name']
shutdown_timer = int(os.environ['shutdown_timer']) shutdown_timer = int(os.environ['shutdown_timer'])
try:
with serial.Serial(device_name, 115200, timeout=1) as ser: with serial.Serial(device_name, 115200, timeout=1) as ser:
inverter_offline_counter = 0 inverter_offline_counter = 0
while True: while True:
@@ -48,3 +49,6 @@ with serial.Serial(device_name, 115200, timeout=1) as ser:
} }
) )
os.system("shutdown now") os.system("shutdown now")
except KeyboardInterrupt:
logger.info("Exiting gracefully")
exit()