Commit dfbcb970a3

dfbcb970a33ff6ff1d731c12f41a073da8bbd1b0

parent: dfd79e9c40

Verified · cmc ci/build: success ci/test: success ci/vuln: success

cmc <hello@cleberg.net> · 2026-09-02 03:57 UTC

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

Deploys stalled at 1% whenever the runner was in the e2e suite: sixty
daemon instances on a VPS sized for one, with nothing holding the
build back, and a plain scp that threw the transfer away on a stall.

install.sh and make deploy-runner copy with rsync --partial --inplace
-z, so a stalled transfer resumes and the binary is compressed on the
wire; install.sh falls back to scp -C where the host has no rsync.

deploy/gitbay-runner.override.conf is a systemd drop-in with Nice=10,
CPUWeight=30 and IOWeight=30, installed by make deploy-runner under
gitbay-runner.service.d. The runner's unit itself was written by hand
on the host and is not in the repository; a drop-in fits whatever it
says.

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