From 4f62a567eec8501518d898c8299d4167ef9c42ea Mon Sep 17 00:00:00 2001 From: Drew Malzahn Date: Thu, 18 Jun 2026 01:47:36 +0000 Subject: [PATCH] ci: Atomically replace share-svc binary on deploy scp overwrites in place, which fails with ETXTBSY ("text file busy") on repeat deploys because systemd is executing /usr/local/bin/share-svc. Copy to a temp path, chmod, then mv it over the destination so rename(2) swaps the dir entry without touching the busy inode. Co-Authored-By: Claude Opus 4.8 --- .gitea/workflows/deploy.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 02cdc89..129e7f5 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -64,8 +64,16 @@ jobs: - name: Copy backend binary + unit file run: | + # Copy to a temp path then atomically rename into place. You can't + # overwrite a running executable in place (ETXTBSY / "Text file busy"), + # but rename(2) just swaps the directory entry while the old inode keeps + # serving the running process until the restart step picks up the new + # binary. chmod first so the exec bit survives the rename (scp doesn't + # preserve mode without -p). scp -i ~/.ssh/deploy_key server/share-svc \ - "$DEPLOY_USER@$DEPLOY_HOST:/usr/local/bin/share-svc" + "$DEPLOY_USER@$DEPLOY_HOST:/usr/local/bin/share-svc.new" + ssh -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" \ + 'chmod 0755 /usr/local/bin/share-svc.new && mv -f /usr/local/bin/share-svc.new /usr/local/bin/share-svc' scp -i ~/.ssh/deploy_key server/share-svc.service \ "$DEPLOY_USER@$DEPLOY_HOST:/etc/systemd/system/share-svc.service"