Spaces:
Build error
Build error
Download entrypoint.sh from WebHub360/multiplechat: direct link, hf CLI and curl.
- Browser
- Download file 4.57 kB
-
https://huggingface.co/spaces/WebHub360/multiplechat/resolve/ec130d94ce50bd698031887a916f00a545f4e152/entrypoint.sh
- Command line
-
hf download hf://spaces/WebHub360/multiplechat@ec130d94ce50bd698031887a916f00a545f4e152/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/WebHub360/multiplechat/resolve/ec130d94ce50bd698031887a916f00a545f4e152/entrypoint.sh
4.57 kB
| set -e | |
| # Enable error tracing | |
| set -x | |
| # Print system information | |
| echo "=== System Information ===" | |
| uname -a | |
| cat /etc/os-release | |
| echo "=== CPU Information ===" | |
| cat /proc/cpuinfo | grep "model name" | head -1 | |
| echo "=== Memory Information ===" | |
| free -h | |
| echo "=== Disk Information ===" | |
| df -h | |
| # Print environment variables | |
| echo "=== Environment Variables ===" | |
| env | sort | |
| # Check Python installation | |
| echo "=== Python Information ===" | |
| which python3.11 || echo "Python 3.11 not found in PATH" | |
| python3.11 --version || echo "Failed to get Python version" | |
| echo "PYTHONPATH: $PYTHONPATH" | |
| echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
| # Check Python libraries | |
| echo "=== Python Libraries ===" | |
| find /usr -name "libpython3.11.so*" 2>/dev/null || echo "Library not found in /usr" | |
| find /lib -name "libpython3.11.so*" 2>/dev/null || echo "Library not found in /lib" | |
| find /usr/local -name "libpython3.11.so*" 2>/dev/null || echo "Library not found in /usr/local" | |
| # Dynamically find and add Python library paths | |
| for path in $(find / -name "libpython3.11.so*" 2>/dev/null | xargs dirname 2>/dev/null | sort | uniq); do | |
| if [ -n "$path" ]; then | |
| echo "Adding Python library path: $path" | |
| export LD_LIBRARY_PATH="$path:$LD_LIBRARY_PATH" | |
| fi | |
| done | |
| echo "Updated LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
| # Make sure `/data/db` directory exists even with persistent storage | |
| mkdir -p /data/db | |
| # If app crashed, mongo didn't stop gracefully. Remove all the old *.lock files | |
| find /data/db -name "*.lock" -type f -exec rm -f {} \; | |
| # Start the local Mongo database | |
| echo "Starting MongoDB..." | |
| mongod & | |
| MONGO_PID=$! | |
| echo "MongoDB started with PID: $MONGO_PID" | |
| # Check if MongoDB is running | |
| sleep 5 | |
| if ! kill -0 $MONGO_PID 2>/dev/null; then | |
| echo "ERROR: MongoDB failed to start! Here's the MongoDB log:" | |
| cat /data/db/mongod.log || echo "No MongoDB log found" | |
| exit 1 | |
| fi | |
| # Create a test file to check filesystem permissions | |
| echo "Testing file system permissions..." | |
| touch /app/test_write_permissions.txt && rm /app/test_write_permissions.txt | |
| echo "Filesystem permissions OK" | |
| # Check if text-generation-launcher exists | |
| echo "Checking for text-generation-launcher..." | |
| which text-generation-launcher || { echo "text-generation-launcher not found!"; exit 1; } | |
| # Start the text-generation-inference process with error redirection | |
| echo "Starting text-generation-inference with model: ${MODEL_NAME}" | |
| text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code > /app/tgi.log 2>&1 & | |
| TGI_PID=$! | |
| echo "Text-generation-inference started with PID: $TGI_PID" | |
| # Check if TGI is running after a brief moment | |
| sleep 10 | |
| if ! kill -0 $TGI_PID 2>/dev/null; then | |
| echo "ERROR: text-generation-inference process died! Here's the log:" | |
| cat /app/tgi.log || echo "No TGI log found" | |
| exit 1 | |
| fi | |
| # Wait for text-generation-inference to start with better error handling | |
| echo "Waiting for text-generation-inference to become available..." | |
| MAX_RETRIES=30 | |
| RETRY_COUNT=0 | |
| while ! curl -s http://127.0.0.1:8080/health > /dev/null; do | |
| RETRY_COUNT=$((RETRY_COUNT+1)) | |
| if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then | |
| echo "ERROR: Maximum retries reached waiting for text-generation-inference!" | |
| echo "TGI log content:" | |
| cat /app/tgi.log || echo "No TGI log found" | |
| exit 1 | |
| fi | |
| echo "Waiting for text-generation-inference... Retry $RETRY_COUNT of $MAX_RETRIES" | |
| sleep 10 | |
| done | |
| # Start the chat-ui process | |
| echo "Starting chat-ui..." | |
| dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000 > /app/chat-ui.log 2>&1 & | |
| CHAT_UI_PID=$! | |
| # Check if chat-ui is running | |
| sleep 5 | |
| if ! kill -0 $CHAT_UI_PID 2>/dev/null; then | |
| echo "ERROR: chat-ui process died! Here's the log:" | |
| cat /app/chat-ui.log || echo "No chat-ui log found" | |
| exit 1 | |
| fi | |
| echo "All services are running! Monitoring processes..." | |
| # Function to check if a service is still running | |
| check_service() { | |
| SERVICE_NAME=$1 | |
| PID=$2 | |
| if ! kill -0 $PID 2>/dev/null; then | |
| echo "ERROR: $SERVICE_NAME with PID $PID has stopped!" | |
| return 1 | |
| fi | |
| return 0 | |
| } | |
| # Monitor all services | |
| while true; do | |
| if ! check_service "MongoDB" $MONGO_PID; then | |
| cat /data/db/mongod.log || echo "No MongoDB log found" | |
| exit 1 | |
| fi | |
| if ! check_service "Text-generation-inference" $TGI_PID; then | |
| cat /app/tgi.log || echo "No TGI log found" | |
| exit 1 | |
| fi | |
| if ! check_service "Chat-UI" $CHAT_UI_PID; then | |
| cat /app/chat-ui.log || echo "No chat-ui log found" | |
| exit 1 | |
| fi | |
| echo "All services running: MongoDB ($MONGO_PID), TGI ($TGI_PID), Chat-UI ($CHAT_UI_PID)" | |
| sleep 60 | |
| done |