improved user experience

This commit is contained in:
ElMoribond 2021-07-12 14:52:19 +02:00 committed by GitHub
parent 8652b454bb
commit b587e83327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -519,8 +519,19 @@ def clipped(obj, frame_shape):
return False
def restart_frigate():
os.kill(os.getpid(), signal.SIGTERM)
def restart_frigate(mqtt_client, topic_prefix, from_ui = 0):
def on_publish(client,userdata,result):
time.sleep(0.67)
rc, docker = 1, "/usr/local/bin/docker"
if os.access(docker, os.X_OK) and os.path.isfile("/var/run/docker.sock"):
rc = sp.Popen(f"{docker} restart $(hostname)", shell=True).wait()
if rc:
# Sometimes you have to wait a long time like this
os.kill(os.getpid(), signal.SIGTERM)
mqtt_client.on_publish = on_publish
mqtt_client.publish(f"{topic_prefix}/restarted", int(from_ui))
class EventsPerSecond: