fix(event): add 401 handling to prevent infinite retry loop on auth failure
- UploadError struct to distinguish fatal auth errors from network errors - Clear buffer and throttle on 401/403 to save bandwidth - Prevent dead-loop retry when token is invalid or expired
This commit is contained in:
41
entrypoint.sh
Normal file
41
entrypoint.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🚀 Starting Tianyan Edge Container..."
|
||||
|
||||
# 1. 启动 NPU 推理服务 (后台)
|
||||
echo "[1/2] Starting infer_server.py..."
|
||||
cd /opt/tianyan
|
||||
python3 python/infer_server.py > /var/log/tianyan/infer.log 2>&1 &
|
||||
INFER_PID=$!
|
||||
|
||||
# 2. 等待 Unix Socket 创建 (最多 20s)
|
||||
echo "⏳ Waiting for inference socket at $INFER_SOCKET..."
|
||||
for i in $(seq 1 20); do
|
||||
if [ -S "${INFER_SOCKET:-/tmp/edge-infer.sock}" ]; then
|
||||
echo "✅ Socket ready. Starting edge-agent..."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ ! -S "${INFER_SOCKET:-/tmp/edge-infer.sock}" ]; then
|
||||
echo "❌ ERROR: Inference socket not created. Check NPU/CANN status."
|
||||
cat /var/log/tianyan/infer.log
|
||||
kill $INFER_PID 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 3. 启动 Go 边缘代理
|
||||
/opt/tianyan/edge-agent -config /opt/tianyan/config/edge.yaml > /var/log/tianyan/agent.log 2>&1 &
|
||||
AGENT_PID=$!
|
||||
|
||||
# 4. 信号捕获与优雅退出
|
||||
trap "echo 'Shutting down...'; kill $INFER_PID $AGENT_PID 2>/dev/null; wait; exit 0" SIGINT SIGTERM
|
||||
|
||||
# 阻塞主进程
|
||||
wait -n
|
||||
EXIT_CODE=$?
|
||||
echo "Process exited with code $EXIT_CODE"
|
||||
kill $INFER_PID $AGENT_PID 2>/dev/null
|
||||
exit $EXIT_CODE
|
||||
Reference in New Issue
Block a user