Skip to content

Commit

Permalink
turn off blinkstick on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Jun 2, 2024
1 parent 1e83f5b commit 87fb7c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions podstatus/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 87fb7c4

Please sign in to comment.