deploy: resumable copies, and a runner drop-in that cannot starve the host !167

merged merged by cmc on 2026-09-02 04:02 UTC · krz/gitbay:deploy-resilience into main

3 files changed, +22 −2

Layout: unified · split

Makefile +4 −1
@@ -71,9 +71,12 @@ deploy-runner: preflight
7171 @echo "==> building $(RUNNER_BIN)"
7272 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner
7373 @echo "==> pushing runner to $(HOST)"
74 scp -P $(PORT) $(RUNNER_BIN) root@$(HOST):/usr/local/bin/gitbay-runner.new
74 rsync --partial --inplace -z -e "ssh -p $(PORT)" $(RUNNER_BIN) root@$(HOST):/usr/local/bin/gitbay-runner.new
75 ssh -p $(PORT) root@$(HOST) 'mkdir -p /etc/systemd/system/gitbay-runner.service.d'
76 rsync -z -e "ssh -p $(PORT)" deploy/gitbay-runner.override.conf root@$(HOST):/etc/systemd/system/gitbay-runner.service.d/override.conf
7577 ssh -p $(PORT) root@$(HOST) 'set -eu; \
7678 chmod 755 /usr/local/bin/gitbay-runner.new; \
7779 mv /usr/local/bin/gitbay-runner.new /usr/local/bin/gitbay-runner; \
80 systemctl daemon-reload; \
7881 systemctl restart gitbay-runner; \
7982 systemctl --no-pager --lines=3 status gitbay-runner'
deploy/gitbay-runner.override.conf added +11
@@ -0,0 +1,11 @@
1# Drop-in for gitbay-runner.service, installed by `make deploy-runner` to
2# /etc/systemd/system/gitbay-runner.service.d/override.conf.
3#
4# A build must never starve the host: the e2e suite alone starts sixty
5# daemon instances, and with nothing holding it back a deploy's scp on
6# the admin sshd stalled at 1%. Lower CPU and IO weight keep sshd,
7# gitbayd and the backup timers responsive while a build runs.
8[Service]
9Nice=10
10CPUWeight=30
11IOWeight=30
deploy/install.sh +7 −1
@@ -8,7 +8,13 @@ bin=dist/gitbayd-linux-amd64
88
99[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; }
1010
11scp -P "$port" "$bin" "root@$host:/usr/local/bin/gitbayd.new"
11# rsync resumes a transfer the host's load stalled and compresses the
12# binary on the wire; scp -C is the fallback where the host has no rsync.
13if ssh -p "$port" "root@$host" 'command -v rsync >/dev/null'; then
14 rsync --partial --inplace -z -e "ssh -p $port" "$bin" "root@$host:/usr/local/bin/gitbayd.new"
15else
16 scp -C -P "$port" "$bin" "root@$host:/usr/local/bin/gitbayd.new"
17fi
1218ssh -p "$port" "root@$host" '
1319 set -eu
1420 chmod 755 /usr/local/bin/gitbayd.new