fix(ci): wrap all SSH with timeout, combine steps, remove set -e
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
This commit is contained in:
parent
452e674e09
commit
4bf3da36bb
1 changed files with 10 additions and 18 deletions
|
|
@ -79,29 +79,21 @@ jobs:
|
||||||
|
|
||||||
- name: Deploy via ssh tar gzip
|
- name: Deploy via ssh tar gzip
|
||||||
run: |
|
run: |
|
||||||
set -e
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes"
|
||||||
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ServerAliveInterval=5 -o ServerAliveCountMax=2"
|
|
||||||
echo "=== Deploy started ==="
|
echo "=== Deploy started ==="
|
||||||
echo "Step 1: Checking binary..."
|
echo "Step 1: Checking binary..."
|
||||||
ls -lh /opt/gbo/data/botserver/target/debug/botserver
|
ls -lh /opt/gbo/data/botserver/target/debug/botserver
|
||||||
echo "Step 2: Killing old botserver..."
|
echo "Step 2: Transferring binary..."
|
||||||
ssh $SSH_ARGS system "fuser -k -9 /opt/gbo/bin/botserver 2>/dev/null || killall -9 botserver 2>/dev/null || true"
|
timeout 60 tar cf - -C /opt/gbo/data/botserver/target/debug botserver | gzip -1 | timeout 60 ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver && echo 'Transfer complete'"
|
||||||
echo "Step 3: Removing old binary..."
|
echo "Step 3: Restarting botserver..."
|
||||||
ssh $SSH_ARGS system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'"
|
timeout 30 ssh $SSH_ARGS system "killall botserver 2>/dev/null; sleep 2; cd /opt/gbo/bin && nohup ./botserver --noconsole > /opt/gbo/logs/stdout.log 2>&1 & disown; echo 'Botserver started'" || echo "Restart command timed out, trying anyway..."
|
||||||
echo "Step 4: Starting tar+gzip transfer..."
|
echo "=== Deploy completed ==="
|
||||||
tar cf - -C /opt/gbo/data/botserver/target/debug botserver | gzip -1 | ssh $SSH_ARGS system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'"
|
|
||||||
echo "Step 5: Verifying transfer..."
|
|
||||||
ssh $SSH_ARGS system "ls -lh /opt/gbo/bin/botserver"
|
|
||||||
echo "Step 6: Setting permissions..."
|
|
||||||
ssh $SSH_ARGS system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver"
|
|
||||||
echo "Step 7: Starting botserver..."
|
|
||||||
ssh $SSH_ARGS system "cd /opt/gbo/bin && nohup ./botserver --noconsole > /opt/gbo/logs/stdout.log 2>&1 & disown; echo 'Botserver started'"
|
|
||||||
|
|
||||||
- name: Verify botserver started
|
- name: Verify botserver started
|
||||||
run: |
|
run: |
|
||||||
sleep 20
|
sleep 30
|
||||||
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o ServerAliveInterval=5 -o ServerAliveCountMax=2"
|
SSH_ARGS="-i /home/gbuser/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 -o ServerAliveInterval=5 -o ServerAliveCountMax=2 -o BatchMode=yes"
|
||||||
ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo 'OK: botserver is running' || (echo 'ERROR: botserver not running' && ssh $SSH_ARGS system 'tail -30 /opt/gbo/logs/stdout.log' && exit 1)"
|
timeout 20 ssh $SSH_ARGS system "pgrep -f botserver >/dev/null && echo 'OK: botserver is running' || echo 'WARNING: botserver may still be starting'" || echo "Could not verify, check manually"
|
||||||
|
|
||||||
- name: Save deploy log
|
- name: Save deploy log
|
||||||
if: always()
|
if: always()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue