apps/console/README.md and lib/watch/types.ts already documented WATCH_AGENT_TOKEN and RAILYARD_WATCH_LIVE as if stacks/gatus-customers/agent.sh existed. It did not -- the console side (agentChecks/recordResults, the /api/v1/watch/agent/* routes) had nothing on the other end to call it, so Watch could never actually turn on. Adds the real box 1 stack: a Gatus probe engine (docker-compose.yml, config.yaml) plus agent.sh, the bridge that pulls the console's check list, regenerates Gatus's config, reads Gatus's own results, and pushes them back -- stateless by design since the console already dedupes by last_checked_at. Plus agent.env.sample, a systemd unit and install.sh (same shape as tools/reconcile-relay-rago). Verified against real components: a real ghcr.io/twin/gatus:stable container and a scratch server wiring the exact shipped lib/watch/http.ts handlers to a MemoryWatchStore, exercised end to end over two passes against a real https://example.com check -- which caught and fixed two real bugs (Gatus refuses to start with zero endpoints; the generated config's timestamp was forcing a gatus restart on every single pass). Container, volume and image removed afterward; apps/console's existing 167 tests and 3 bundle tests pass unchanged (this item touched no console source file).
37 lines
1.6 KiB
Bash
Executable File
37 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# install.sh: install Railyard Watch's checks agent + its Gatus probe engine
|
|
# on box 1 (PY2.2).
|
|
# sudo ./install.sh # units + env sample, start gatus, enable the agent
|
|
# sudo ./install.sh run # one agent pass now, then show the log
|
|
# sudo ./install.sh status # unit + container status
|
|
# The code runs from this checkout (RAILYARD_SRC, default /srv/src/railyard).
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SRC="${RAILYARD_SRC:-/srv/src/railyard}"
|
|
UNIT_DIR="${UNIT_DIR:-/etc/systemd/system}"
|
|
ETC="${PRODUCTS_ETC:-/etc/products}"
|
|
[[ $EUID -eq 0 ]] || { echo "run as root" >&2; exit 1; }
|
|
command -v docker >/dev/null || { echo "docker is required" >&2; exit 1; }
|
|
command -v jq >/dev/null || { echo "jq is required" >&2; exit 1; }
|
|
|
|
case "${1:-install}" in
|
|
install)
|
|
sed "s#/srv/src/railyard#$SRC#g" "$HERE/systemd/watch-agent.service" >"$UNIT_DIR/watch-agent.service"
|
|
chmod 644 "$UNIT_DIR/watch-agent.service"
|
|
[[ -f "$ETC/watch-agent.env" ]] || install -m 640 "$HERE/agent.env.sample" "$ETC/watch-agent.env"
|
|
echo "edit $ETC/watch-agent.env (WATCH_CONSOLE_URL, WATCH_AGENT_TOKEN) before enabling, if you have not already"
|
|
systemctl daemon-reload
|
|
systemctl enable --now watch-agent.service
|
|
systemctl status watch-agent.service --no-pager -l || true
|
|
;;
|
|
run)
|
|
systemctl start watch-agent.service || true
|
|
"$HERE/agent.sh" once
|
|
;;
|
|
status)
|
|
systemctl status watch-agent.service --no-pager -l || true
|
|
docker compose -f "$HERE/docker-compose.yml" ps
|
|
;;
|
|
*) sed -n '2,6p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 2 ;;
|
|
esac
|