Skip to content

Commit

Permalink
更新 start.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Samiya authored Mar 3, 2024
1 parent 37c27f3 commit 856c29b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ CHECK_INTERVAL=30

# 检查CONFIG_PATH是否已设置
if [ -z "$CONFIG_PATH" ]; then
echo "CONFIG_PATH未设置。仅运行python main.py。"
python main.py &
echo "CONFIG_PATH未设置。仅运行python ./main.py。"
python ./main.py &
MAIN_PY_PID=$!
echo "python main.py 的 PID 为 $MAIN_PY_PID"
echo "python ./main.py 的 PID 为 $MAIN_PY_PID"
wait $MAIN_PY_PID
exit 0 # 运行python main.py后退出
exit 0 # 运行python ./main.py后退出
fi

# 从CONFIG_PATH提取仓库URL和子目录路径
Expand All @@ -36,7 +36,7 @@ initialize_or_update_repo() {
if git fetch --depth=1 origin main && git checkout FETCH_HEAD; then
# 如果获取和检出成功,检查是否有变化
if ! diff -r "$TMP_DIR/$SUB_DIR" "$TARGET_DIR" > /dev/null 2>&1; then
echo "检测到$CONFIG_PATH下的文件变化。更新并重新运行python main.py..."
echo "检测到$CONFIG_PATH下的文件变化。更新并重新运行python ./main.py..."
# 终止当前运行的main.py进程
if [ ! -z "$MAIN_PY_PID" ]; then
kill $MAIN_PY_PID
Expand All @@ -46,9 +46,9 @@ initialize_or_update_repo() {
# 复制新文件
cp -rT "$TMP_DIR/$SUB_DIR/" "$TARGET_DIR/"
# 重新运行python main.py并记录PID
python main.py &
python ./main.py &
MAIN_PY_PID=$!
echo "python main.py 的 PID 为 $MAIN_PY_PID"
echo "python ./main.py 的 PID 为 $MAIN_PY_PID"
else
echo "未检测到变化。"
fi
Expand Down

0 comments on commit 856c29b

Please sign in to comment.