Spaces:
Runtime error
Runtime error
Update entrypoint.sh
Browse files- entrypoint.sh +24 -9
entrypoint.sh
CHANGED
|
@@ -1,22 +1,37 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
#
|
| 4 |
mkdir -p /data/db
|
| 5 |
-
# If app crashed,
|
| 6 |
-
find /data/db -name "*.lock" -type f -exec rm -f {} \;
|
|
|
|
| 7 |
# Start the local Mongo database
|
| 8 |
mongod &
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Start the chat-ui process
|
| 17 |
dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000
|
|
|
|
| 18 |
# Wait for any process to exit
|
| 19 |
wait -n
|
| 20 |
|
| 21 |
-
# Exit with status of process that
|
| 22 |
-
exit $?
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# Ensure `/data/db` directory exists even with persistent storage
|
| 4 |
mkdir -p /data/db
|
| 5 |
+
# If app crashed, remove old *.lock files to allow MongoDB to restart
|
| 6 |
+
find /data/db -name "*.lock" -type f -exec rm -f {} \;
|
| 7 |
+
|
| 8 |
# Start the local Mongo database
|
| 9 |
mongod &
|
| 10 |
|
| 11 |
+
# Wait for MongoDB to be ready
|
| 12 |
+
until nc -z localhost 27017; do
|
| 13 |
+
echo "Waiting for MongoDB to start..."
|
| 14 |
+
sleep 2
|
| 15 |
+
done
|
| 16 |
+
|
| 17 |
+
# Set the Hugging Face API URL and Token
|
| 18 |
+
HF_API_URL="https://api-inference.huggingface.co/models/${MODEL_NAME}"
|
| 19 |
+
HF_TOKEN=${HF_TOKEN}
|
| 20 |
|
| 21 |
+
# Ensure API token is set
|
| 22 |
+
if [ -z "$HF_TOKEN" ]; then
|
| 23 |
+
echo "Error: HF_TOKEN is not set. Exiting."
|
| 24 |
+
exit 1
|
| 25 |
+
fi
|
| 26 |
+
|
| 27 |
+
# Configure Chat-UI to use the Hugging Face Inference API
|
| 28 |
+
export HF_API_URL HF_TOKEN
|
| 29 |
|
| 30 |
# Start the chat-ui process
|
| 31 |
dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000
|
| 32 |
+
|
| 33 |
# Wait for any process to exit
|
| 34 |
wait -n
|
| 35 |
|
| 36 |
+
# Exit with the status of the first process that exits
|
| 37 |
+
exit $?
|