#!/usr/bin/env bash
# Run the one-time hotel sync pipeline in the background (survives terminal disconnect).
# Logs to logs/run-once-YYYYMMDD-HHMMSS.log

set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"

mkdir -p logs
LOGFILE="logs/run-once-$(date +%Y%m%d-%H%M%S).log"

nohup node src/index.js --run >> "$LOGFILE" 2>&1 &
PID=$!

echo "Pipeline started in background."
echo "  PID: $PID"
echo "  Log: $LOGFILE"
echo ""
echo "To watch progress: tail -f $LOGFILE"
echo "To stop: kill $PID"
