#!/bin/sh # 启用错误检测 set -e # 定义错误处理函数 error_handler() { echo "脚本在第 ${LINENO} 行发生错误" exit 1 } # 捕获 ERR 信号,调用错误处理函数 trap 'error_handler' ERR # clone 代码 # 检查环境变量是否存在且为1 if [ "${GIT_CLONE_PROXY}" = "1" ]; then echo "克隆 aggregator(使用 ghproxy 代理)" git clone https://mirror.ghproxy.com/https://github.com/wzdnzd/aggregator.git else echo "克隆 aggregator" git clone https://github.com/wzdnzd/aggregator.git fi # 安装依赖(已在 Dockerfile 中完成,这里可以省略) # pip3 install pyYAML tqdm requests -i https://mirrors.cloud.tencent.com/pypi/simple # 设置代理 export https_proxy=$PROXY http_proxy=$PROXY all_proxy=$PROXY # 运行代码 cd /app/aggregator && python -u subscribe/collect.py -si python /app/merged2upload.py # 启动一个简单的 HTTP 服务器来保持容器运行并响应健康检查 echo "Starting HTTP server on port 8080" python -m http.server 8080