diff --git a/podstatus/app.py b/podstatus/app.py index ba853a5..8ea15d3 100644 --- a/podstatus/app.py +++ b/podstatus/app.py @@ -1,6 +1,7 @@ import logging import time import random +import atexit from threading import Thread, Event from kubernetes import client, config as k8sconfig, watch from kubernetes.config import ConfigException @@ -58,6 +59,17 @@ logging.fatal(f"BlinkStick setup failed: {e}") bstick = None + +# Ensure Blinkstick is turned off on exit +def turn_off_blinkstick(): + if bstick: + logging.info("Turning off BlinkStick") + for i in range(config.BLINKSTICK_TOTAL_LED): + bstick.set_color(channel=0, index=i, hex="#000000") + + +atexit.register(turn_off_blinkstick) + # Threading setup stop_event = Event()