mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:07:35 +01:00
The bash daemon was deleted in Session 4 of killing-the-bash-daemon; Fleet Runner (the desktop poller) is the local executor now. This retires the 'daemon' name from everything describing the live system — constants (DAEMON_*→RUNNER_*), types (DaemonStateKey→RunnerStateKey), the status banner component, state-derivation fns, control props, CSS classes (ui-control-fleet-daemon→-runner), and comments/UI strings. Backward-compat shims (no breakage to deployed Fleet Runner installs): - src/lib/constants/daemon.ts re-exports RUNNER_* under the old DAEMON_* names for the desktop Electron build until it points at the runner path. - Fleet Doctor reads runner.env, falls back to legacy daemon.env. Deliberately KEPT as 'daemon' (they name the genuinely-dead/legacy thing): the deprecated DAEMON_TOKEN bearer contract, the /api/agent/daemon 410 tombstone, the legacyDaemon developer download, and historical killing-the-bash-daemon references. systemctl daemon-reload / NX_DAEMON left untouched (not ours). tsc clean · eslint 0 errors · test:home 97/97 · smoke 44/44 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87 lines
2.5 KiB
Bash
87 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# Generate + push systemd units, launch scripts, and Caddy vhosts for every
|
|
# app in apps.conf. Idempotent. Does NOT touch the four pre-existing services
|
|
# (bridge, fleetcrown, orangecat, revampit) or any /opt/<app>/.env.
|
|
# Usage: sync-infra.sh [app ...] (no args = all)
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
|
|
apps=("$@")
|
|
[ ${#apps[@]} -eq 0 ] && mapfile -t apps < <(app_names)
|
|
|
|
# One-time: Caddy import dir + import line
|
|
box 'sudo mkdir -p /etc/caddy/apps.d
|
|
grep -q "import apps.d" /etc/caddy/Caddyfile || \
|
|
echo "import apps.d/*.caddy" | sudo tee -a /etc/caddy/Caddyfile >/dev/null'
|
|
|
|
for app in "${apps[@]}"; do
|
|
app_lookup "$app"
|
|
echo "=== sync $NAME (port $PORT) ==="
|
|
|
|
launch=$(cat <<EOF
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
HERE="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
if [ -f "\$HERE/.env" ]; then set -a; source "\$HERE/.env"; set +a; fi
|
|
export NODE_ENV=production PORT=$PORT HOSTNAME=127.0.0.1
|
|
SERVER_JS=\$(find "\$HERE" -maxdepth 4 -name server.js -not -path "*node_modules*" | head -1)
|
|
if [ -n "\$SERVER_JS" ]; then exec /usr/bin/node "\$SERVER_JS"; fi
|
|
# Non-Next services define their own entrypoint via START_CMD in .env
|
|
exec bash -c "\${START_CMD:?no server.js found and START_CMD unset}"
|
|
EOF
|
|
)
|
|
|
|
unit=$(cat <<EOF
|
|
[Unit]
|
|
Description=$NAME application server (self-hosted, generated by sync-infra.sh)
|
|
After=network-online.target postgresql.service
|
|
Wants=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=ubuntu
|
|
WorkingDirectory=/opt/$NAME/app
|
|
ExecStart=/opt/$NAME/app/launch.sh
|
|
Restart=on-failure
|
|
RestartSec=3
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
)
|
|
|
|
box "sudo mkdir -p /opt/$NAME/app && sudo chown -R ubuntu:ubuntu /opt/$NAME
|
|
cat > /opt/$NAME/app/launch.sh <<'LAUNCH_EOF'
|
|
$launch
|
|
LAUNCH_EOF
|
|
chmod +x /opt/$NAME/app/launch.sh
|
|
sudo tee /etc/systemd/system/$NAME-app.service >/dev/null <<'UNIT_EOF'
|
|
$unit
|
|
UNIT_EOF
|
|
sudo systemctl daemon-reload && sudo systemctl enable $NAME-app >/dev/null 2>&1"
|
|
|
|
if [ "$DOMAINS" != "-" ]; then
|
|
caddy_domains="${DOMAINS//,/, }"
|
|
vhost=$(cat <<EOF
|
|
$caddy_domains {
|
|
encode zstd gzip
|
|
handle_path /uploads/* {
|
|
root * /opt/$NAME/uploads
|
|
file_server
|
|
}
|
|
reverse_proxy 127.0.0.1:$PORT {
|
|
flush_interval -1
|
|
}
|
|
}
|
|
EOF
|
|
)
|
|
box "sudo tee /etc/caddy/apps.d/$NAME.caddy >/dev/null <<'CADDY_EOF'
|
|
$vhost
|
|
CADDY_EOF
|
|
sudo mkdir -p /opt/$NAME/uploads && sudo chown ubuntu:ubuntu /opt/$NAME/uploads"
|
|
fi
|
|
done
|
|
|
|
box 'sudo caddy validate --config /etc/caddy/Caddyfile >/dev/null && sudo systemctl reload caddy && echo "caddy reloaded OK"'
|