ccm commited on
Commit
3ff1053
·
verified ·
1 Parent(s): 5f7408d

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +24 -15
entrypoint.sh CHANGED
@@ -1,22 +1,31 @@
1
  #!/bin/bash
 
2
 
3
- # Make sure `/data/db` directory exists even with persistent storage
4
- mkdir -p /data/db
5
- # If app crashed, mongo didn't stop gracefully. Remove all the old *.lock files
6
- find /data/db -name "*.lock" -type f -exec rm -f {} \;
7
- # Start the local Mongo database
8
- mongod &
9
 
10
- # Start the text-generation-inference process
11
- text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code &
 
 
12
 
13
- # Wait for text-generation-inference to start
14
- curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
 
 
 
 
 
 
 
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 exited first
22
  exit $?
 
1
  #!/bin/bash
2
+ set -euo pipefail
3
 
4
+ # --- Start Mongo ---
5
+ mkdir -p "$HOME/data/db" "$HOME/logs"
6
+ mongod --dbpath "$HOME/data/db" \
7
+ --bind_ip 127.0.0.1 \
8
+ --logpath "$HOME/logs/mongod.log" \
9
+ --fork
10
 
11
+ # --- Start the Python proxy with dotenv (DO NOT source .env in bash) ---
12
+ # Loads /app/.env first, then overrides with /app/.env.local
13
+ npx dotenv -e /app/.env -e /app/.env.local -c -- \
14
+ sh -lc 'python3 -m uvicorn proxy:app --host 127.0.0.1 --port 8000' &
15
 
16
+ # --- Wait for proxy health ---
17
+ for i in {1..40}; do
18
+ if curl -fsS http://127.0.0.1:8000/healthz >/dev/null; then
19
+ echo "[entrypoint] Proxy is up"
20
+ break
21
+ fi
22
+ echo "[entrypoint] Waiting for proxy..."
23
+ sleep 0.5
24
+ done
25
 
26
+ # --- Start Chat-UI under dotenv as well ---
27
+ npx dotenv -e /app/.env -e /app/.env.local -c -- \
28
+ node /app/build/index.js -- --host 0.0.0.0 --port 3000
 
29
 
30
+ wait -n
31
  exit $?