From 8fdf3c8e4e107adb5ac23308629e1969c535f714 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 1 Jul 2026 17:13:38 +0000 Subject: [PATCH] Async SSH for parallel status checks; Kuma 2 --base-path via CLI arg Co-Authored-By: Claude Opus 4.8 (1M context) --- docker-compose.yml | 3 +-- updater/src/index.js | 18 +++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5d8bf44..896f203 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,7 @@ services: image: louislam/uptime-kuma:2 security_opt: - apparmor=unconfined - environment: - - UPTIME_KUMA_BASE_PATH=/monitor + command: ["node", "server/server.js", "--base-path=/monitor"] volumes: - kuma_data:/app/data ports: diff --git a/updater/src/index.js b/updater/src/index.js index 88469b6..572ef81 100644 --- a/updater/src/index.js +++ b/updater/src/index.js @@ -1,8 +1,11 @@ import Fastify from 'fastify' import crypto from 'crypto' -import { execSync } from 'child_process' +import { exec, execSync } from 'child_process' +import { promisify } from 'util' import { deployMap } from '../deploy-map.js' +const execAsync = promisify(exec) + const app = Fastify({ logger: true }) const WEBHOOK_SECRET = process.env.WEBHOOK_SECRET || '' const SSH_KEY = process.env.SSH_KEY_PATH || '/root/.ssh/id_ed25519' @@ -20,12 +23,13 @@ function verifySignature(body, signature) { return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature || '')) } -function sshGet(host, cmd) { +async function sshGet(host, cmd) { try { - return execSync( - `ssh -i ${SSH_KEY} -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${host} "${cmd}"`, - { timeout: 15_000, encoding: 'utf8' } - ).trim() + const { stdout } = await execAsync( + `ssh -i ${SSH_KEY} -o StrictHostKeyChecking=no -o ConnectTimeout=2 root@${host} "${cmd}"`, + { timeout: 8_000 } + ) + return stdout.trim() } catch { return null } @@ -49,7 +53,7 @@ async function refreshStatus(repo) { if (!target) return null const [current, latest] = await Promise.all([ - Promise.resolve(sshGet(target.host, `git -C ${target.path} rev-parse HEAD 2>/dev/null || echo not-deployed`)), + sshGet(target.host, `git -C ${target.path} rev-parse HEAD 2>/dev/null || echo not-deployed`), getForgejoCommit(repo), ])