added keyboard interupt handling
This commit is contained in:
4
main.py
4
main.py
@@ -28,6 +28,7 @@ ntfy_token = os.environ['NTFY_Token']
|
||||
device_name = os.environ['device_name']
|
||||
shutdown_timer = int(os.environ['shutdown_timer'])
|
||||
|
||||
try:
|
||||
with serial.Serial(device_name, 115200, timeout=1) as ser:
|
||||
inverter_offline_counter = 0
|
||||
while True:
|
||||
@@ -48,3 +49,6 @@ with serial.Serial(device_name, 115200, timeout=1) as ser:
|
||||
}
|
||||
)
|
||||
os.system("shutdown now")
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Exiting gracefully")
|
||||
exit()
|
||||
Reference in New Issue
Block a user