feat: add worker install and deploy
Все проверки выполнены успешно
CI / test (push) Successful in 2m24s
Docker / Build and publish worker image (push) Successful in 13m24s

Этот коммит содержится в:
Gleb Tv
2026-07-19 13:21:11 +03:00
родитель 579a14b403
Коммит 3256dcdc12
16 изменённых файлов: 870 добавлений и 80 удалений

Просмотреть файл

@@ -11,8 +11,7 @@ usage() {
Usage: sudo ./scripts/install-systemd.sh [--binary PATH] [--env PATH] [--no-start]
Installs rsmon-worker as /usr/local/bin/rsmon-worker and configures systemd.
If --env is omitted on a first install, an example file is installed and the
service is not started until its token and password are configured.
--env is required and must contain RSMON_URL and RSMON_TOKEN.
USAGE
}
@@ -56,44 +55,13 @@ if [ ! -x "$BINARY" ]; then
fi
fi
if ! command -v chromium >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates chromium libcap2-bin tzdata
else
printf 'Warning: Chromium is not installed; browser-backed HTTP checks will fail.\n' >&2
fi
if [ -z "$ENV_FILE" ]; then
printf '%s\n' '--env is required; use a mode-0600 file containing RSMON_URL and RSMON_TOKEN.' >&2
exit 2
fi
if ! getent group rsmon-worker >/dev/null; then
groupadd --system rsmon-worker
fi
if ! id rsmon-worker >/dev/null 2>&1; then
useradd --system --gid rsmon-worker --home-dir /var/lib/rsmon-worker --create-home --shell /usr/sbin/nologin rsmon-worker
fi
install -d -m 0755 /etc/rsmon-worker
install -d -o rsmon-worker -g rsmon-worker -m 0750 /var/lib/rsmon-worker /var/lib/rsmon-worker/webapp /var/lib/rsmon-worker/cluster
install -m 0755 "$BINARY" /usr/local/bin/rsmon-worker
install -m 0644 "$ROOT_DIR/packaging/systemd/rsmon-worker.service" /etc/systemd/system/rsmon-worker.service
if [ -n "$ENV_FILE" ]; then
install -m 0600 "$ENV_FILE" /etc/rsmon-worker/worker.env
elif [ ! -f /etc/rsmon-worker/worker.env ]; then
install -m 0600 "$ROOT_DIR/packaging/systemd/worker.env.example" /etc/rsmon-worker/worker.env
START_SERVICE=0
printf 'Installed /etc/rsmon-worker/worker.env; configure it before starting the service.\n'
fi
if command -v setcap >/dev/null 2>&1; then
setcap cap_net_raw=+ep /usr/local/bin/rsmon-worker || true
fi
systemctl daemon-reload
systemctl enable rsmon-worker.service
if [ "$START_SERVICE" -eq 1 ]; then
systemctl restart rsmon-worker.service
systemctl --no-pager --full status rsmon-worker.service
else
printf 'Start after configuration with: systemctl start rsmon-worker\n'
ARGS=(install --binary "$BINARY" --env-file "$ENV_FILE")
if [ "$START_SERVICE" -eq 0 ]; then
ARGS+=(--no-start)
fi
exec "$BINARY" "${ARGS[@]}"