APP-Backend / start.sh
Luca448's picture
fix(security): require access key on every /api route, drop browser agent and leaked secrets file
8a83d52
Raw History Blame Contribute Delete
846 Bytes
#!/bin/bash
# Start script for Hugging Face Space (Node.js + IServ filter)
# 0. IServ filter (127.0.0.1:7862, only reachable from this container) as its own unix user. sudo resets the
# environment, so it sees only what is passed here: the token, not ISERV_PASSWORD. Restarted if it ever dies, so a
# crash cannot take the other apps down with it.
(while true; do
sudo -u iserv_runner env FILTER_ONLY=1 HF_HUB_OFFLINE=1 PYTHONDONTWRITEBYTECODE=1 API_BEARER_TOKEN="$API_BEARER_TOKEN" /opt/filter-venv/bin/python -m uvicorn app:app --app-dir /app/iserv-filter --host 127.0.0.1 --port 7862 --log-level warning
sleep 5
done) &
# 1. Start Node.js App (Port 7860) in the background
echo "Starting Node.js server..."
node server.js &
NODE_PID=$!
# Wait for any process to exit
wait -n
# Exit with status of process that exited first
exit $?