| export NODE_ENV=production | |
| # Start Redis in the background with essential flags for containerized environments | |
| echo "Starting Redis server..." | |
| redis-server --daemonize yes --protected-mode no | |
| # Wait for Redis to be ready (up to 30 seconds) | |
| COUNTER=0 | |
| until redis-cli ping > /dev/null 2>&1 || [ $COUNTER -eq 30 ]; do | |
| echo "Waiting for Redis ($COUNTER)..." | |
| sleep 1 | |
| ((COUNTER++)) | |
| done | |
| if [ $COUNTER -eq 30 ]; then | |
| echo "โ ๏ธ Redis failed to start or is unreachable, but continuing for app boot..." | |
| else | |
| echo "โ Redis is ready!" | |
| fi | |
| # Use the PORT environment variable if provided by HF, otherwise default to 7860 | |
| export PORT="${PORT:-7860}" | |
| echo "๐ Starting GLMPilot on port $PORT..." | |
| # Start the Node.js application | |
| npm run start -w packages/server | |