From 499d06c36652b42683a574e5dc87264e373a9c94 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Tue, 21 Nov 2023 01:28:11 +0300 Subject: [PATCH] Add Unix socket support for go2rtc This commit introduces Unix socket support for go2rtc. The configuration file for go2rtc has been updated to include a new key "unix_listen" with a value of "/tmp/go2rtc.sock". This change allows go2rtc to listen on a Unix socket instead of a TCP port. Additionally, the nginx configuration has been updated to use the Unix socket for communication with go2rtc. The previous TCP server configuration has been removed. This change should improve performance by eliminating the TCP overhead. --- docker/main/rootfs/usr/local/go2rtc/create_config.py | 2 ++ docker/main/rootfs/usr/local/nginx/conf/nginx.conf | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py index 7c6b7b56e..974bd7f1b 100644 --- a/docker/main/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py @@ -48,6 +48,8 @@ if go2rtc_config.get("api") is None: elif go2rtc_config["api"].get("origin") is None: go2rtc_config["api"]["origin"] = "*" +go2rtc_config["api"]["unix_listen"] = "/tmp/go2rtc.sock" + # Need to set default location for HA config if go2rtc_config.get("hass") is None: go2rtc_config["hass"] = {"config": "/config"} diff --git a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf index 1d3b80de3..dfdfe1be1 100644 --- a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf +++ b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf @@ -55,8 +55,7 @@ http { } upstream go2rtc { - server 127.0.0.1:1984; - keepalive 1024; + server unix:/tmp/go2rtc.sock; } server {