#!/usr/bin/env bash # Deploy teleo-pipeline to VPS. # Usage: ./deploy.sh [--restart] # # Pulls latest from current branch, updates venv, optionally restarts service. # Run from the VPS as the teleo user, or via SSH: # ssh teleo@77.42.65.182 'cd /opt/teleo-eval/pipeline && ./deploy.sh --restart' set -euo pipefail DEPLOY_DIR="/opt/teleo-eval/pipeline" VENV_DIR="${DEPLOY_DIR}/.venv" SERVICE="teleo-pipeline" cd "$DEPLOY_DIR" echo "=== Pulling latest ===" git pull --ff-only echo "=== Updating venv ===" "${VENV_DIR}/bin/pip" install -q -e ".[dev]" 2>/dev/null || \ "${VENV_DIR}/bin/pip" install -q -e . echo "=== Syntax check ===" "${VENV_DIR}/bin/python3" -c " import ast, pathlib, sys errors = [] for f in pathlib.Path('.').rglob('*.py'): if '.venv' in str(f): continue try: ast.parse(f.read_text()) except SyntaxError as e: errors.append(f'{f}: {e}') if errors: for e in errors: print(f'SYNTAX ERROR: {e}', file=sys.stderr) sys.exit(1) print('All Python files pass syntax check') " if [[ "${1:-}" == "--restart" ]]; then echo "=== Restarting ${SERVICE} ===" sudo systemctl restart "$SERVICE" sleep 2 if systemctl is-active --quiet "$SERVICE"; then echo "=== ${SERVICE} is running ===" systemctl status "$SERVICE" --no-pager -l | head -15 else echo "ERROR: ${SERVICE} failed to start" >&2 journalctl -u "$SERVICE" --no-pager -n 20 exit 1 fi else echo "=== Deploy complete (service not restarted — use --restart to restart) ===" fi