CognxSafeTrack commited on
Commit
a524013
·
1 Parent(s): 6019d2d

fix: startup script compatibility for standard sh

Browse files
Files changed (1) hide show
  1. start.sh +6 -5
start.sh CHANGED
@@ -8,8 +8,8 @@ pnpm --filter @repo/database db:push || echo "[DB] db:push failed, continuing an
8
 
9
  # 2. Start API Server
10
  echo "[API] Starting API Gateway on port ${PORT:-8080}..."
11
- # Using direct path to avoid pnpm overhead and potential filter issues
12
- npx tsx apps/api/src/index.ts &
13
  API_PID=$!
14
 
15
  # 3. Wait a bit for API to initialize
@@ -17,13 +17,14 @@ sleep 5
17
 
18
  # 4. Start WhatsApp Worker
19
  echo "[WORKER] Starting WhatsApp Worker on internal port 8081..."
20
- npx tsx apps/whatsapp-worker/src/index.ts &
21
  WORKER_PID=$!
22
 
23
  echo "[SYSTEM] Both services are starting. Monitoring processes..."
24
 
25
- # 5. Wait and handle exits
26
- wait -n $API_PID $WORKER_PID
 
27
 
28
  echo "[SYSTEM] One of the services exited. Shutting down..."
29
  kill $API_PID $WORKER_PID 2>/dev/null
 
8
 
9
  # 2. Start API Server
10
  echo "[API] Starting API Gateway on port ${PORT:-8080}..."
11
+ # Using pnpm start is more reliable to find local binaries like tsx
12
+ pnpm --filter api start &
13
  API_PID=$!
14
 
15
  # 3. Wait a bit for API to initialize
 
17
 
18
  # 4. Start WhatsApp Worker
19
  echo "[WORKER] Starting WhatsApp Worker on internal port 8081..."
20
+ pnpm --filter whatsapp-worker start &
21
  WORKER_PID=$!
22
 
23
  echo "[SYSTEM] Both services are starting. Monitoring processes..."
24
 
25
+ # 5. Wait for both processes
26
+ # Note: wait without -n is more compatible with standard 'sh'
27
+ wait $API_PID $WORKER_PID
28
 
29
  echo "[SYSTEM] One of the services exited. Shutting down..."
30
  kill $API_PID $WORKER_PID 2>/dev/null