party-lock: use Docker SDK instead of docker kill CLI

The docker binary is not available inside the party-lock container,
so switch to the Python Docker SDK via unix socket.
This commit is contained in:
2026-07-02 23:33:43 -07:00
parent 67bb68b097
commit ad9a5b4e02
+10 -1
View File
@@ -2,12 +2,15 @@
# /// script
# dependencies = [
# "paho-mqtt>=2.0",
# "docker>=7.0",
# ]
# ///
import os
import stat
import time
import docker
import paho.mqtt.client as mqtt
MQTT_HOST = os.environ.get("MQTT_HOST", "mosquitto")
@@ -25,7 +28,13 @@ def rebuild_acl():
f.write("\n".join(lines) + "\n")
os.chmod(ACL_PATH, stat.S_IRWXU)
os.chown(ACL_PATH, 1883, 1883)
os.system("docker kill -s HUP mosquitto 2>/dev/null || true")
try:
dc = docker.DockerClient(base_url="unix://var/run/docker.sock")
mosq = dc.containers.get("mosquitto")
mosq.kill(signal="HUP")
except Exception:
pass
time.sleep(0.05)
def on_message(client, userdata, msg):
global locked