background daemon now disables heartbeat for itself

This commit is contained in:
Joel Klimont 2021-10-01 01:04:05 +02:00
parent a81fd4204b
commit bb4483b141
2 changed files with 12 additions and 4 deletions

View file

@ -10,6 +10,7 @@ SPI_BUS = 1
SPI_DEVICE = 2 SPI_DEVICE = 2
SPI_SPEED = 1000000 SPI_SPEED = 1000000
SPI_BUFFER_SIZE = 32 SPI_BUFFER_SIZE = 32
SPI_HEALTH = True
spi = spidev.SpiDev() spi = spidev.SpiDev()
spi.open(SPI_BUS, SPI_DEVICE) spi.open(SPI_BUS, SPI_DEVICE)
@ -179,8 +180,13 @@ class Spi(object):
health_check_thread.setDaemon(True) health_check_thread.setDaemon(True)
health_check_thread.start() health_check_thread.start()
@staticmethod
def disable_health_check():
global SPI_HEALTH
SPI_HEALTH = False
@staticmethod @staticmethod
def health_check_loop(): def health_check_loop():
while True: while SPI_HEALTH:
Spi.health_check() Spi.health_check()
time.sleep(0.5) time.sleep(0.5)

View file

@ -12,8 +12,9 @@ import socket
RUN_IP_CHECK = False RUN_IP_CHECK = False
try: try:
from compLib.Display import Display from compLib.Display import Display
from compLib.Spi import Spi
except Exception as e: except Exception as e:
logstash_logger.warning(f"Could not import display for battery output {str(e)}") logstash_logger.warning(f"Could not import display or spi for ip output {str(e)}")
__run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-1.0 fdsrc ! video/x-h264,width=1280,height=720,framerate=30/1,noise-reduction=1,profile=high,stream-format=byte-stream ! h264parse ! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://localhost/live/stream\"""" __run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-1.0 fdsrc ! video/x-h264,width=1280,height=720,framerate=30/1,noise-reduction=1,profile=high,stream-format=byte-stream ! h264parse ! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://localhost/live/stream\""""
@ -53,11 +54,12 @@ if __name__ == '__main__':
ip_output = None ip_output = None
if RUN_IP_CHECK and IP_OUTPUT: if RUN_IP_CHECK and IP_OUTPUT:
try: try:
Spi.disable_health_check()
ip_output = threading.Thread(target=write_ip_to_screen) ip_output = threading.Thread(target=write_ip_to_screen)
ip_output.start() ip_output.start()
logstash_logger.info("starting battery checker - DONE") logstash_logger.info("starting ip output - DONE")
except Exception as e: except Exception as e:
logstash_logger.error(f"could not start battery checker -> {str(e)}") logstash_logger.error(f"could not start ip output -> {str(e)}")
if STREAM_RASPI: if STREAM_RASPI:
logstash_logger.info("starting gstreamer background process") logstash_logger.info("starting gstreamer background process")