新增Windows代理程序支持

This commit is contained in:
Alex Yang
2025-12-07 18:15:50 +08:00
parent ccc43fe70e
commit 2efe02682c
16 changed files with 4392 additions and 115 deletions

View File

@@ -48,35 +48,18 @@ start_agent() {
return 0
fi
echo "🚀 正在启动 monitor-agent(工作目录:${WORK_DIR}..."
# 新增:检查并切换工作目录
if [ ! -d "${WORK_DIR}" ]; then
echo "⚠️ 工作目录 ${WORK_DIR} 不存在,正在创建..."
mkdir -p "${WORK_DIR}"
if [ $? -ne 0 ]; then
echo "❌ 创建工作目录 ${WORK_DIR} 失败!"
exit 1
fi
fi
# 切换到工作目录(关键:程序将在此目录下运行)
cd "${WORK_DIR}" || {
echo "❌ 切换到工作目录 ${WORK_DIR} 失败!"
exit 1
}
# 创建日志目录
echo "🚀 正在启动 monitor-agent..."
# 创建日志目录(如果不存在)
mkdir -p "$(dirname ${LOG_FILE})"
# 后台启动程序注意cd仅影响当前子进程需在同一行执行
# 后台启动程序重定向日志记录PID
nohup "${AGENT_PATH}" ${START_ARGS} > "${LOG_FILE}" 2>&1 &
AGENT_PID=$!
echo "${AGENT_PID}" > "${PID_FILE}"
# 等待检查启动状态
# 等待2秒检查是否启动成功
sleep 2
if check_running; then
echo "✅ monitor-agent 启动成功PID: ${AGENT_PID},工作目录:${WORK_DIR}"
echo "✅ monitor-agent 启动成功PID: ${AGENT_PID}"
echo "日志文件:${LOG_FILE}"
else
echo "❌ monitor-agent 启动失败!请查看日志:${LOG_FILE}"