WebHub360 commited on
Commit
f375d99
·
verified ·
1 Parent(s): b22d367

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +41 -15
entrypoint.sh CHANGED
@@ -1,29 +1,45 @@
1
  #!/bin/bash
 
2
 
3
- # Skip MongoDB startup since we're using external MongoDB
4
 
5
- # Display model being loaded
6
- echo "Starting text-generation-inference with model: ${MODEL_NAME}"
 
 
7
 
8
- # Start the text-generation-inference process with error logging
9
- text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code > /tmp/tgi.log 2>&1 &
 
10
  TGI_PID=$!
11
  echo "Text-generation-inference started with PID: $TGI_PID"
12
 
13
  # Check if process is running
14
  sleep 5
15
  if ! kill -0 $TGI_PID 2>/dev/null; then
16
- echo "ERROR: text-generation-inference process died! Log:"
17
- cat /tmp/tgi.log
18
  exit 1
19
  fi
20
 
21
  # Wait for text-generation-inference to start
22
  echo "Waiting for text-generation-inference to be available..."
23
- curl --retry 60 --retry-delay 10 --retry-connrefused http://127.0.0.1:8080/health
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  # Start the chat-ui process
26
  echo "Starting chat-ui..."
 
27
  dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000 &
28
  CHAT_UI_PID=$!
29
 
@@ -34,12 +50,22 @@ if ! kill -0 $CHAT_UI_PID 2>/dev/null; then
34
  exit 1
35
  fi
36
 
 
37
  echo "All services are now running"
38
 
39
- # Wait for any process to exit
40
- wait -n
41
-
42
- # Exit with status of process that exited first
43
- EXIT_CODE=$?
44
- echo "A process exited with code: $EXIT_CODE"
45
- exit $EXIT_CODE
 
 
 
 
 
 
 
 
 
 
1
  #!/bin/bash
2
+ set -e
3
 
4
+ echo "Starting entrypoint script with MODEL_NAME: ${MODEL_NAME}"
5
 
6
+ # Display system information
7
+ echo "=== System Information ==="
8
+ uname -a
9
+ nvidia-smi || echo "Warning: nvidia-smi failed, GPU may not be available"
10
 
11
+ # Start the text-generation-inference service
12
+ echo "Starting text-generation-inference with model: ${MODEL_NAME}"
13
+ text-generation-launcher --model-id ${MODEL_NAME} --num-shard 1 --port 8080 --trust-remote-code &
14
  TGI_PID=$!
15
  echo "Text-generation-inference started with PID: $TGI_PID"
16
 
17
  # Check if process is running
18
  sleep 5
19
  if ! kill -0 $TGI_PID 2>/dev/null; then
20
+ echo "ERROR: text-generation-inference process died! Checking logs..."
 
21
  exit 1
22
  fi
23
 
24
  # Wait for text-generation-inference to start
25
  echo "Waiting for text-generation-inference to be available..."
26
+ MAX_RETRIES=60
27
+ RETRY_COUNT=0
28
+ while ! curl -s http://127.0.0.1:8080/health > /dev/null; do
29
+ RETRY_COUNT=$((RETRY_COUNT+1))
30
+ if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
31
+ echo "ERROR: Maximum retries reached waiting for text-generation-inference!"
32
+ exit 1
33
+ fi
34
+ echo "Waiting for text-generation-inference... Retry $RETRY_COUNT of $MAX_RETRIES"
35
+ sleep 10
36
+ done
37
+
38
+ echo "Text-generation-inference is now available at http://127.0.0.1:8080"
39
 
40
  # Start the chat-ui process
41
  echo "Starting chat-ui..."
42
+ cd /app
43
  dotenv -e /app/.env -c -- node /app/build/index.js -- --host 0.0.0.0 --port 3000 &
44
  CHAT_UI_PID=$!
45
 
 
50
  exit 1
51
  fi
52
 
53
+ echo "Chat UI is now available at http://0.0.0.0:3000"
54
  echo "All services are now running"
55
 
56
+ # Monitor all services
57
+ while true; do
58
+ # Check if TGI is still running
59
+ if ! kill -0 $TGI_PID 2>/dev/null; then
60
+ echo "ERROR: text-generation-inference process died!"
61
+ exit 1
62
+ fi
63
+
64
+ # Check if Chat-UI is still running
65
+ if ! kill -0 $CHAT_UI_PID 2>/dev/null; then
66
+ echo "ERROR: chat-ui process died!"
67
+ exit 1
68
+ fi
69
+
70
+ sleep 60
71
+ done