Files
AI-tianyan/start.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# 一键启动脚本
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
echo "=========================================="
echo " Tianyan Edge - 启动脚本"
echo "=========================================="
# 检查模型
if [ ! -f model/model.om ]; then
echo "[错误] model/model.om 不存在,请先转换模型"
echo "使用方法: atc --model=yolov8n.onnx --framework=5 --output=model/model.om --soc_version=Ascend310B4 --input_format=NCHW --input_shape=\"images:1,3,640,640\""
exit 1
fi
# 创建必要的目录
mkdir -p logs
# 启动推理服务(后台)
echo "[1/2] 启动推理服务..."
if systemctl is-active --quiet edge-infer 2>/dev/null; then
echo " edge-infer 已在运行"
else
python3 python/infer_server.py > logs/infer.log 2>&1 &
INFER_PID=$!
echo " 推理服务 PID: $INFER_PID"
sleep 2
fi
# 启动 Go Agent
echo "[2/2] 启动 Go Agent..."
if systemctl is-active --quiet edge-agent 2>/dev/null; then
echo " edge-agent 已在运行"
else
./build/edge-agent -config config/edge.yaml 2>&1 | tee logs/agent.log &
AGENT_PID=$!
echo " Agent PID: $AGENT_PID"
fi
echo ""
echo "启动完成!按 Ctrl+C 停止"
echo "推理日志: logs/infer.log"
echo "Agent日志: logs/agent.log"
# 等待
wait