diff --git a/docker/host-updater.py b/docker/host-updater.py index 354f8f6..d1743fc 100755 --- a/docker/host-updater.py +++ b/docker/host-updater.py @@ -18,7 +18,7 @@ LOG_FILE = os.environ.get("HOST_UPDATER_LOG_FILE", "/opt/synapsis/updater.log") UPDATE_SCRIPT = os.environ.get("HOST_UPDATER_SCRIPT", "/opt/synapsis/update-local.sh") INSTALL_DIR = os.environ.get("INSTALL_DIR", "/opt/synapsis") -status_lock = threading.Lock() +status_lock = threading.RLock() current_process = None @@ -72,14 +72,14 @@ def watch_process(process): exit_code = process.wait() with status_lock: current_process = None - update_status( - status="success" if exit_code == 0 else "error", - message="Synapsis update completed." if exit_code == 0 else "Synapsis update failed.", - lastFinishedAt=now_iso(), - lastExitCode=exit_code, - lastError=None if exit_code == 0 else f"Updater exited with code {exit_code}", - pid=None, - ) + update_status( + status="success" if exit_code == 0 else "error", + message="Synapsis update completed." if exit_code == 0 else "Synapsis update failed.", + lastFinishedAt=now_iso(), + lastExitCode=exit_code, + lastError=None if exit_code == 0 else f"Updater exited with code {exit_code}", + pid=None, + ) def start_update_process(): @@ -104,8 +104,8 @@ def start_update_process(): update_status(pid=current_process.pid) - thread = threading.Thread(target=watch_process, args=(current_process,), daemon=True) - thread.start() + thread = threading.Thread(target=watch_process, args=(current_process,), daemon=True) + thread.start() class ThreadedUnixServer(socketserver.ThreadingMixIn, socketserver.UnixStreamServer): diff --git a/scripts/docker-publish.sh b/scripts/docker-publish.sh index abffd42..f9b1206 100755 --- a/scripts/docker-publish.sh +++ b/scripts/docker-publish.sh @@ -5,7 +5,7 @@ set -eu IMAGE_REPO="${IMAGE_REPO:-ghcr.io/gnosyslabs/synapsis}" PACKAGE_API="${PACKAGE_API:-/orgs/GnosysLabs/packages/container/synapsis/versions?per_page=100}" BUILDER="${BUILDER:-colima}" -PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}" +PLATFORMS="${PLATFORMS:-linux/amd64}" DATE_PREFIX="${DATE_PREFIX:-$(date -u +%Y.%m.%d)}" SOURCE_REPO="${SOURCE_REPO:-https://github.com/GnosysLabs/Synapsis}" PRUNE_BUILD_CACHE="${PRUNE_BUILD_CACHE:-1}" diff --git a/src/lib/host-updater.ts b/src/lib/host-updater.ts index e598057..ec50930 100644 --- a/src/lib/host-updater.ts +++ b/src/lib/host-updater.ts @@ -1,6 +1,7 @@ import http from 'http'; const DEFAULT_SOCKET_PATH = '/var/run/synapsis-updater/updater.sock'; +const REQUEST_TIMEOUT_MS = 4000; export interface HostUpdaterStatus { available: boolean; @@ -69,6 +70,10 @@ function requestUpdater(method: 'GET' | 'POST', path: string, body?: unknown) } ); + request.setTimeout(REQUEST_TIMEOUT_MS, () => { + request.destroy(new Error('Host updater request timed out')); + }); + request.on('error', (error) => { reject(error); });