feat: SSH tunnel launch script for fine-tuner (IONOS blocks port 5432 externally)
This commit is contained in:
parent
499e600239
commit
d8deecdb32
43
packages/fine-tuner/scripts/start.sh
Normal file
43
packages/fine-tuner/scripts/start.sh
Normal file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# start.sh — Launch fine-tuner with SSH tunnel to Erik's PostgreSQL
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/start.sh # run fine-tuner
|
||||
# ./scripts/start.sh --dry-run # dry run (no training)
|
||||
# ./scripts/start.sh --status # show status only
|
||||
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
TUNNEL_PORT=5434
|
||||
SSH_HOST="erik"
|
||||
REMOTE_PG_PORT=5432
|
||||
|
||||
echo "[start.sh] Opening SSH tunnel to Erik:${REMOTE_PG_PORT} → localhost:${TUNNEL_PORT}"
|
||||
|
||||
# Kill any existing tunnel on that port
|
||||
pkill -f "ssh.*${TUNNEL_PORT}:localhost:${REMOTE_PG_PORT}" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# Open tunnel in background
|
||||
ssh -N -L "${TUNNEL_PORT}:localhost:${REMOTE_PG_PORT}" "${SSH_HOST}" &
|
||||
TUNNEL_PID=$!
|
||||
|
||||
# Wait for tunnel to be ready
|
||||
sleep 3
|
||||
echo "[start.sh] Tunnel established (PID: ${TUNNEL_PID})"
|
||||
|
||||
# Cleanup tunnel on exit
|
||||
cleanup() {
|
||||
echo "[start.sh] Closing SSH tunnel (PID: ${TUNNEL_PID})"
|
||||
kill "${TUNNEL_PID}" 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Run fine-tuner with tunnel DB URL
|
||||
export DATABASE_URL="postgresql://llm:llm_secure_2026@localhost:${TUNNEL_PORT}/llm_gateway"
|
||||
export GATEWAY_URL="https://llm-gateway.context-x.org"
|
||||
export OLLAMA_URL="http://localhost:11434"
|
||||
|
||||
echo "[start.sh] Starting fine-tuner..."
|
||||
python3 src/main.py "$@"
|
||||
Loading…
x
Reference in New Issue
Block a user