feat(scripts): add --deploy flag to build-linux-docker.sh
Deploys wzp-relay to both relay servers after building: - manwe@manwehs:/home/manwe/wzp (tmux session 5) - manwe@pangolin.manko.yoga:/home/manwe/wzp-linux (tmux session 0) Captures current relay args from /proc, stops via tmux C-c, restarts with same args. Also fixes hardcoded branch default to use current git branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ set -euo pipefail
|
||||
# ./scripts/build-linux-docker.sh --pull Git pull before building
|
||||
# ./scripts/build-linux-docker.sh --clean Clean Rust target cache
|
||||
# ./scripts/build-linux-docker.sh --install Download binaries locally after build
|
||||
# ./scripts/build-linux-docker.sh --deploy Download + deploy wzp-relay to relay servers
|
||||
|
||||
REMOTE_HOST="SepehrHomeserverdk"
|
||||
BASE_DIR="/mnt/storage/manBuilder"
|
||||
@@ -21,17 +22,26 @@ SSH_OPTS="-o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax=
|
||||
# (opus-DRED-v2 as of 2026-04-11). Override with `WZP_BRANCH=<name> ./build-linux-docker.sh`
|
||||
# if you need a different one — e.g. to rebuild the relay from a feature
|
||||
# branch for A/B testing.
|
||||
WZP_BRANCH="${WZP_BRANCH:-opus-DRED-v2}"
|
||||
WZP_BRANCH="${WZP_BRANCH:-$(git -C "$(dirname "$0")/.." branch --show-current 2>/dev/null || echo "experimental-ui")}"
|
||||
|
||||
# Relay servers to deploy to when --deploy is passed.
|
||||
# Format: "user@host:binary_dir:tmux_session"
|
||||
RELAY_SERVERS=(
|
||||
"manwe@manwehs:/home/manwe/wzp:5"
|
||||
"manwe@pangolin.manko.yoga:/home/manwe/wzp-linux:0"
|
||||
)
|
||||
|
||||
DO_PULL=1
|
||||
DO_CLEAN=0
|
||||
DO_INSTALL=0
|
||||
DO_DEPLOY=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--pull) DO_PULL=1 ;;
|
||||
--pull) DO_PULL=1 ;;
|
||||
--no-pull) DO_PULL=0 ;;
|
||||
--clean) DO_CLEAN=1 ;;
|
||||
--clean) DO_CLEAN=1 ;;
|
||||
--install) DO_INSTALL=1 ;;
|
||||
--deploy) DO_DEPLOY=1; DO_INSTALL=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -149,6 +159,41 @@ echo " Monitor: ssh $REMOTE_HOST 'tail -f /tmp/wzp-linux-build.log'"
|
||||
echo " Status: ssh $REMOTE_HOST 'tail -5 /tmp/wzp-linux-build.log'"
|
||||
echo ""
|
||||
|
||||
# Deploy wzp-relay to a single relay server.
|
||||
# $1 = "user@host" $2 = binary_dir $3 = tmux_session
|
||||
deploy_relay() {
|
||||
local TARGET="$1"
|
||||
local BINARY_DIR="$2"
|
||||
local TMUX_SESSION="$3"
|
||||
local DEPLOY_OPTS="-o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new -o LogLevel=ERROR"
|
||||
|
||||
log "Deploying wzp-relay to $TARGET ($BINARY_DIR) ..."
|
||||
|
||||
# Copy new binary atomically
|
||||
scp $DEPLOY_OPTS "$LOCAL_OUTPUT/wzp-relay" "$TARGET:$BINARY_DIR/wzp-relay.new"
|
||||
ssh $DEPLOY_OPTS "$TARGET" "chmod +x $BINARY_DIR/wzp-relay.new && mv $BINARY_DIR/wzp-relay.new $BINARY_DIR/wzp-relay"
|
||||
|
||||
# Capture current args, stop, restart in same tmux session
|
||||
ssh $DEPLOY_OPTS "$TARGET" bash <<DEPLOY
|
||||
set -euo pipefail
|
||||
RELAY_PID=\$(pgrep -f './wzp-relay' | head -1 || true)
|
||||
if [ -z "\$RELAY_PID" ]; then
|
||||
echo "WARNING: no running wzp-relay found on $TARGET — binary replaced, start it manually"
|
||||
exit 0
|
||||
fi
|
||||
# Capture args from /proc (everything after the binary name)
|
||||
RELAY_ARGS=\$(tr '\\0' ' ' < /proc/\$RELAY_PID/cmdline | sed 's|^[^ ]* ||; s| *\$||')
|
||||
echo "Stopping relay PID \$RELAY_PID (args: \$RELAY_ARGS)"
|
||||
tmux send-keys -t $TMUX_SESSION C-c 2>/dev/null || kill -TERM \$RELAY_PID 2>/dev/null || true
|
||||
sleep 2
|
||||
echo "Starting new relay..."
|
||||
tmux send-keys -t $TMUX_SESSION "cd $BINARY_DIR && ./wzp-relay \$RELAY_ARGS" Enter 2>/dev/null || true
|
||||
echo "Deploy done on $TARGET"
|
||||
DEPLOY
|
||||
|
||||
log "Deployed to $TARGET"
|
||||
}
|
||||
|
||||
# Optionally wait and download
|
||||
if [ "$DO_INSTALL" = "1" ]; then
|
||||
log "Waiting for build..."
|
||||
@@ -170,5 +215,19 @@ if [ "$DO_INSTALL" = "1" ]; then
|
||||
log "Done! Binaries in $LOCAL_OUTPUT/"
|
||||
else
|
||||
err "Build failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Deploy to relay servers
|
||||
if [ "$DO_DEPLOY" = "1" ]; then
|
||||
if [ ! -f "$LOCAL_OUTPUT/wzp-relay" ]; then
|
||||
err "wzp-relay binary not found in $LOCAL_OUTPUT — install step may have failed"
|
||||
exit 1
|
||||
fi
|
||||
for SERVER in "${RELAY_SERVERS[@]}"; do
|
||||
IFS=: read -r TARGET BINARY_DIR TMUX_SESSION <<< "$SERVER"
|
||||
deploy_relay "$TARGET" "$BINARY_DIR" "$TMUX_SESSION"
|
||||
done
|
||||
log "All relay servers updated!"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user