WebHub360 commited on
Commit
e3d7201
·
verified ·
1 Parent(s): 113b8d3

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +43 -2
entrypoint.sh CHANGED
@@ -1,22 +1,63 @@
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
 
3
+ # Enable error tracing
4
+ set -e
5
+
6
+ # Print debugging info
7
+ echo "Starting entrypoint script with MODEL_NAME: ${MODEL_NAME}"
8
+
9
  # Make sure `/data/db` directory exists even with persistent storage
10
  mkdir -p /data/db
11
  # If app crashed, mongo didn't stop gracefully. Remove all the old *.lock files
12
  find /data/db -name "*.lock" -type f -exec rm -f {} \;
13
  # Start the local Mongo database
14
+ echo "Starting MongoDB..."
15
  mongod &
16
+ MONGO_PID=$!
17
+ echo "MongoDB started with PID: $MONGO_PID"
18
+
19
+ # Check if MongoDB is running
20
+ sleep 5
21
+ if ! kill -0 $MONGO_PID 2>/dev/null; then
22
+ echo "ERROR: MongoDB failed to start!"
23
+ exit 1
24
+ fi
25
 
26
  # Start the text-generation-inference process
27
+ echo "Starting text-generation-inference with model: ${MODEL_NAME}"
28
  text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code &
29
+ TGI_PID=$!
30
+ echo "Text-generation-inference started with PID: $TGI_PID"
31
+
32
+ # Check if TGI is running after a brief moment
33
+ sleep 10
34
+ if ! kill -0 $TGI_PID 2>/dev/null; then
35
+ echo "ERROR: text-generation-inference process died! Check logs for details."
36
+ exit 1
37
+ fi
38
 
39
  # Wait for text-generation-inference to start
40
+ echo "Waiting for text-generation-inference to become available..."
41
  curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
42
 
43
  # Start the chat-ui process
44
+ echo "Starting chat-ui..."
45
+ dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000 &
46
+ CHAT_UI_PID=$!
47
+
48
+ # Check if chat-ui is running
49
+ sleep 5
50
+ if ! kill -0 $CHAT_UI_PID 2>/dev/null; then
51
+ echo "ERROR: chat-ui process died! Check logs for details."
52
+ exit 1
53
+ fi
54
+
55
+ echo "All services are running!"
56
+
57
  # Wait for any process to exit
58
  wait -n
59
 
60
  # Exit with status of process that exited first
61
+ EXIT_CODE=$?
62
+ echo "A process exited with code: $EXIT_CODE"
63
+ exit $EXIT_CODE