forked from vast-ai/vast-pyworker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_check.sh
executable file
·30 lines (26 loc) · 1.22 KB
/
init_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
packages=("flask" "nltk" "pycryptodome" "requests" "numpy")
FULL_ADDR="$REPORT_ADDR/worker_status/"
for pkg in "${packages[@]}"; do
if ! pip show "$pkg" &> /dev/null; then
echo "$pkg is not installed"
curl $FULL_ADDR -X POST -d "{\"error_msg\" : \"package failed installing\", \"id\" : \"$CONTAINER_ID\"}" -H 'Content-Type: application/json'
return 1
else
echo "$pkg is installed"
fi
done
# Define the target command
WATCH_CMD="python3 $SERVER_DIR/logwatch_json.py"
MODEL_LAUNCH_CMD="text-generation-launcher"
AUTH_CMD="$SERVER_DIR/tgi_server.py"
# Get the process IDs (PIDs) of processes matching the target command
PIDS1=$(ps aux | grep "$WATCH_CMD" | grep -v grep | awk '{print $2}')
PIDS2=$(ps aux | grep "$MODEL_LAUNCH_CMD" | grep -v grep | awk '{print $2}')
PIDS3=$(ps aux | grep "$AUTH_CMD" | grep -v grep | awk '{print $2}')
if ([ -z "$PIDS1" ] || [ -z "$PIDS2" ] || [ -z "$PIDS3" ]); then
echo "not all server component processes are running"
curl $FULL_ADDR -X POST -d "{\"error_msg\" : \"not all server component processes are running\", \"id\" : \"$CONTAINER_ID\"}" -H 'Content-Type: application/json'
return 1
else
echo "all component processes are running"
fi