xjf6b commited on
Commit
786e5e3
·
verified ·
1 Parent(s): e21b9db

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +46 -20
entrypoint.sh CHANGED
@@ -2,30 +2,56 @@
2
 
3
  set -e
4
 
5
- echo "开始执行脚本"
 
6
 
7
- # 确保我们在正确的目录
8
- cd /app
9
 
10
- # clone 代码
11
- if [ "${GIT_CLONE_PROXY}" = "1" ]; then
12
- echo "克隆 aggregator(使用 ghproxy 代理)"
13
- git clone https://mirror.ghproxy.com/https://github.com/wzdnzd/aggregator.git
14
- else
15
- echo "克隆 aggregator"
16
- git clone https://github.com/wzdnzd/aggregator.git
17
- fi
18
 
19
- # 设置代理
20
- export https_proxy=$PROXY http_proxy=$PROXY all_proxy=$PROXY
21
 
22
- # 运行代码
23
- echo "运行 collect.py"
24
- cd /app/aggregator && python -u subscribe/collect.py -si
25
 
26
- echo "运行 merged2upload.py"
27
- python /app/merged2upload.py
28
 
29
- # 启动一个简单的 HTTP 服务器来保持容器运行并响应健康检查
 
 
 
 
 
 
 
 
 
 
30
  echo "启动 HTTP 服务器在端口 8080"
31
- python -m http.server 8080
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  set -e
4
 
5
+ run_script() {
6
+ echo "开始执行脚本"
7
 
8
+ # 确保我们在正确的目录
9
+ cd /app
10
 
11
+ # clone 代码
12
+ if [ "${GIT_CLONE_PROXY}" = "1" ]; then
13
+ echo "克隆 aggregator(使用 ghproxy 代理)"
14
+ git clone https://mirror.ghproxy.com/https://github.com/wzdnzd/aggregator.git
15
+ else
16
+ echo "克隆 aggregator"
17
+ git clone https://github.com/wzdnzd/aggregator.git
18
+ fi
19
 
20
+ # 设置代理
21
+ export https_proxy=$PROXY http_proxy=$PROXY all_proxy=$PROXY
22
 
23
+ # 运行代码
24
+ echo "运行 collect.py"
25
+ cd /app/aggregator && python -u subscribe/collect.py -si
26
 
27
+ echo "运行 merged2upload.py"
28
+ python /app/merged2upload.py
29
 
30
+ # 清理克隆的代码
31
+ cd /app && rm -rf aggregator
32
+ }
33
+
34
+ # 立即运行一次脚本
35
+ run_script
36
+
37
+ # 启动调度器
38
+ python /app/scheduler.py &
39
+
40
+ # 启动一个简单的 HTTP 服务器来提供merged.txt文件
41
  echo "启动 HTTP 服务器在端口 8080"
42
+ python -c "
43
+ import http.server
44
+ import socketserver
45
+
46
+ class Handler(http.server.SimpleHTTPRequestHandler):
47
+ def do_GET(self):
48
+ self.send_response(200)
49
+ self.send_header('Content-type', 'text/plain')
50
+ self.end_headers()
51
+ with open('/app/merged.txt', 'rb') as file:
52
+ self.wfile.write(file.read())
53
+
54
+ with socketserver.TCPServer(('', 8080), Handler) as httpd:
55
+ print('服务器运行在端口 8080...')
56
+ httpd.serve_forever()
57
+ "