Fix remotedev scp failing when prior binaries are still running.

Stop remote processes with pkill -f before upload so long binary names are matched and busy executables can be overwritten.
This commit is contained in:
2026-07-18 15:23:29 +02:00
parent 2605c3b346
commit 458f14e74f
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -19,6 +19,12 @@ else
REMOTEDEV_SSH := $(REMOTEDEV_HOST)
endif
# pkill -x cannot match names longer than 15 chars (Linux /proc/*/comm). Use -f on argv.
# Stop before scp so running binaries are not busy when overwritten.
REMOTEDEV_KILL = pkill -f './clustercanvas-server( |$$)' >/dev/null 2>&1 || true; \
pkill -f './clustercanvas-webui( |$$)' >/dev/null 2>&1 || true; \
sleep 0.2
service:
cd service && go run ./cmd/server
@@ -46,13 +52,14 @@ remotedev:
# scp only needs OpenSSH on the remote (rsync is often missing on minimal VMs).
# Leave ~ unquoted so the remote shell expands REMOTEDEV_DIR=~/... correctly.
ssh "$(REMOTEDEV_SSH)" "mkdir -p $(REMOTEDEV_DIR)/web $(REMOTEDEV_DIR)/config"
ssh "$(REMOTEDEV_SSH)" "cd $(REMOTEDEV_DIR) 2>/dev/null || true; $(REMOTEDEV_KILL)"
scp bin/clustercanvas-server bin/clustercanvas-webui "$(REMOTEDEV_SSH):$(REMOTEDEV_DIR)/"
ssh "$(REMOTEDEV_SSH)" "rm -rf $(REMOTEDEV_DIR)/web && mkdir -p $(REMOTEDEV_DIR)/web"
scp -r webui/dist/. "$(REMOTEDEV_SSH):$(REMOTEDEV_DIR)/web/"
@echo "Starting on $(REMOTEDEV_SSH) — open http://<vm-ip>:$(WEBUI_PORT) (Ctrl+C stops both)"
# Kill in a separate ssh so pkill -f cannot match this start script's own argv.
ssh "$(REMOTEDEV_SSH)" "cd $(REMOTEDEV_DIR) 2>/dev/null || true; $(REMOTEDEV_KILL)"
ssh -t "$(REMOTEDEV_SSH)" "cd $(REMOTEDEV_DIR) && \
pkill -x clustercanvas-server >/dev/null 2>&1 || true; \
pkill -x clustercanvas-webui >/dev/null 2>&1 || true; \
trap 'kill 0' EXIT INT TERM; \
export CLUSTERCANVAS_CONFIG_KEY='$(REMOTEDEV_CONFIG_KEY)'; \
export CLUSTERCANVAS_CONFIG_DIR=\"\$$PWD/config\"; \