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
71 @echo "==> building $(RUNNER_BIN)" 71 @echo "==> building $(RUNNER_BIN)"
72 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner 72 $(CROSS) go build -trimpath -ldflags='$(LDFLAGS)' -o $(RUNNER_BIN) ./cmd/gitbay-runner
73 @echo "==> pushing runner to $(HOST)" 73 @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
75 ssh -p $(PORT) root@$(HOST) 'set -eu; \ 77 ssh -p $(PORT) root@$(HOST) 'set -eu; \
76 chmod 755 /usr/local/bin/gitbay-runner.new; \ 78 chmod 755 /usr/local/bin/gitbay-runner.new; \
77 mv /usr/local/bin/gitbay-runner.new /usr/local/bin/gitbay-runner; \ 79 mv /usr/local/bin/gitbay-runner.new /usr/local/bin/gitbay-runner; \
80 systemctl daemon-reload; \
78 systemctl restart gitbay-runner; \ 81 systemctl restart gitbay-runner; \
79 systemctl --no-pager --lines=3 status gitbay-runner' 82 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
8 8
9[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; } 9[ -f "$bin" ] || { echo "build first: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $bin ./cmd/gitbayd" >&2; exit 1; }
10 10
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
12ssh -p "$port" "root@$host" ' 18ssh -p "$port" "root@$host" '
13 set -eu 19 set -eu
14 chmod 755 /usr/local/bin/gitbayd.new 20 chmod 755 /usr/local/bin/gitbayd.new