issue-ai/entrypoint.sh

25 lines
581 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# entrypoint.sh — 同时启动 Next.js Server 和 Monitor Worker
HOSTNAME=0.0.0.0 node /app/server.js &
SERVER_PID=$!
cd /app && node scripts/monitor-worker.js &
WORKER_PID=$!
cleanup() {
echo "Stopping Server (PID=$SERVER_PID) and Worker (PID=$WORKER_PID)..."
kill $SERVER_PID 2>/dev/null
kill $WORKER_PID 2>/dev/null
wait $SERVER_PID 2>/dev/null
wait $WORKER_PID 2>/dev/null
echo "Shutdown complete."
}
trap cleanup SIGTERM SIGINT
# 等待任一进程退出(需要 Bash 4.3+
wait -n $SERVER_PID $WORKER_PID
EXIT_CODE=$?
cleanup
exit $EXIT_CODE