@whyour/qinglong 2.19.0-0 → 2.19.0-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,142 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.api;
4
+
5
+ message EnvItem {
6
+ optional int32 id = 1;
7
+ optional string name = 2;
8
+ optional string value = 3;
9
+ optional string remarks = 4;
10
+ optional int32 status = 5;
11
+ optional int64 position = 6;
12
+ }
13
+
14
+ message GetEnvsRequest { string searchValue = 1; }
15
+
16
+ message CreateEnvRequest { repeated EnvItem envs = 1; }
17
+
18
+ message UpdateEnvRequest { EnvItem env = 1; }
19
+
20
+ message DeleteEnvsRequest { repeated int32 ids = 1; }
21
+
22
+ message MoveEnvRequest {
23
+ int32 id = 1;
24
+ int32 fromIndex = 2;
25
+ int32 toIndex = 3;
26
+ }
27
+
28
+ message DisableEnvsRequest { repeated int32 ids = 1; }
29
+
30
+ message EnableEnvsRequest { repeated int32 ids = 1; }
31
+
32
+ message UpdateEnvNamesRequest {
33
+ repeated int32 ids = 1;
34
+ string name = 2;
35
+ }
36
+
37
+ message GetEnvByIdRequest { int32 id = 1; }
38
+
39
+ message EnvsResponse {
40
+ int32 code = 1;
41
+ repeated EnvItem data = 2;
42
+ optional string message = 3;
43
+ }
44
+
45
+ message EnvResponse {
46
+ int32 code = 1;
47
+ EnvItem data = 2;
48
+ optional string message = 3;
49
+ }
50
+
51
+ message Response {
52
+ int32 code = 1;
53
+ optional string message = 2;
54
+ }
55
+
56
+ message SystemNotifyRequest {
57
+ string title = 1;
58
+ string content = 2;
59
+ }
60
+
61
+ message ExtraScheduleItem {
62
+ string schedule = 1;
63
+ }
64
+
65
+ message CronItem {
66
+ optional int32 id = 1;
67
+ optional string command = 2;
68
+ optional string schedule = 3;
69
+ optional string name = 4;
70
+ repeated string labels = 5;
71
+ optional int32 sub_id = 6;
72
+ repeated ExtraScheduleItem extra_schedules = 7;
73
+ optional string task_before = 8;
74
+ optional string task_after = 9;
75
+ optional int32 status = 10;
76
+ optional string log_path = 11;
77
+ optional int32 pid = 12;
78
+ optional int64 last_running_time = 13;
79
+ optional int64 last_execution_time = 14;
80
+ }
81
+
82
+ message CreateCronRequest {
83
+ string command = 1;
84
+ string schedule = 2;
85
+ optional string name = 3;
86
+ repeated string labels = 4;
87
+ optional int32 sub_id = 5;
88
+ repeated ExtraScheduleItem extra_schedules = 6;
89
+ optional string task_before = 7;
90
+ optional string task_after = 8;
91
+ }
92
+
93
+ message UpdateCronRequest {
94
+ int32 id = 1;
95
+ optional string command = 2;
96
+ optional string schedule = 3;
97
+ optional string name = 4;
98
+ repeated string labels = 5;
99
+ optional int32 sub_id = 6;
100
+ repeated ExtraScheduleItem extra_schedules = 7;
101
+ optional string task_before = 8;
102
+ optional string task_after = 9;
103
+ }
104
+
105
+ message DeleteCronsRequest { repeated int32 ids = 1; }
106
+
107
+ message CronsResponse {
108
+ int32 code = 1;
109
+ repeated CronItem data = 2;
110
+ optional string message = 3;
111
+ }
112
+
113
+ message CronResponse {
114
+ int32 code = 1;
115
+ CronItem data = 2;
116
+ optional string message = 3;
117
+ }
118
+
119
+ message CronDetailRequest { string log_path = 1; }
120
+
121
+ message CronDetailResponse {
122
+ int32 code = 1;
123
+ CronItem data = 2;
124
+ optional string message = 3;
125
+ }
126
+
127
+ service Api {
128
+ rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {}
129
+ rpc CreateEnv(CreateEnvRequest) returns (EnvsResponse) {}
130
+ rpc UpdateEnv(UpdateEnvRequest) returns (EnvResponse) {}
131
+ rpc DeleteEnvs(DeleteEnvsRequest) returns (Response) {}
132
+ rpc MoveEnv(MoveEnvRequest) returns (EnvResponse) {}
133
+ rpc DisableEnvs(DisableEnvsRequest) returns (Response) {}
134
+ rpc EnableEnvs(EnableEnvsRequest) returns (Response) {}
135
+ rpc UpdateEnvNames(UpdateEnvNamesRequest) returns (Response) {}
136
+ rpc GetEnvById(GetEnvByIdRequest) returns (EnvResponse) {}
137
+ rpc SystemNotify(SystemNotifyRequest) returns (Response) {}
138
+ rpc GetCronDetail(CronDetailRequest) returns (CronDetailResponse) {}
139
+ rpc CreateCron(CreateCronRequest) returns (CronResponse) {}
140
+ rpc UpdateCron(UpdateCronRequest) returns (CronResponse) {}
141
+ rpc DeleteCrons(DeleteCronsRequest) returns (Response) {}
142
+ }
@@ -0,0 +1,26 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.cron;
4
+
5
+ service Cron {
6
+ rpc addCron(AddCronRequest) returns (AddCronResponse);
7
+ rpc delCron(DeleteCronRequest) returns (DeleteCronResponse);
8
+ }
9
+
10
+ message ISchedule { string schedule = 1; }
11
+
12
+ message ICron {
13
+ string id = 1;
14
+ string schedule = 2;
15
+ string command = 3;
16
+ repeated ISchedule extra_schedules = 4;
17
+ string name = 5;
18
+ }
19
+
20
+ message AddCronRequest { repeated ICron crons = 1; }
21
+
22
+ message AddCronResponse {}
23
+
24
+ message DeleteCronRequest { repeated string ids = 1; }
25
+
26
+ message DeleteCronResponse {}
@@ -0,0 +1,22 @@
1
+ syntax = "proto3";
2
+
3
+ package com.ql.health;
4
+
5
+ message HealthCheckRequest {
6
+ string service = 1;
7
+ }
8
+
9
+ message HealthCheckResponse {
10
+ enum ServingStatus {
11
+ UNKNOWN = 0;
12
+ SERVING = 1;
13
+ NOT_SERVING = 2;
14
+ SERVICE_UNKNOWN = 3;
15
+ }
16
+ ServingStatus status = 1;
17
+ }
18
+
19
+ service Health {
20
+ rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
21
+ rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
22
+ }
@@ -18,14 +18,13 @@ ARG QL_MAINTAINER="whyour"
18
18
  LABEL maintainer="${QL_MAINTAINER}"
19
19
  ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
20
20
  ARG QL_BRANCH=develop
21
+ ARG PYTHON_SHORT_VERSION=3.10
21
22
 
22
23
  ENV QL_DIR=/ql \
23
24
  QL_BRANCH=${QL_BRANCH} \
24
25
  LANG=C.UTF-8 \
25
26
  SHELL=/bin/bash \
26
- PS1="\u@\h:\w \$ " \
27
- PYTHONPATH= \
28
- PYTHON_SHORT_VERSION=
27
+ PS1="\u@\h:\w \$ "
29
28
 
30
29
  COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
31
30
  COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
@@ -50,15 +49,14 @@ RUN set -x && \
50
49
  apt-get clean && \
51
50
  ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
52
51
  echo "Asia/Shanghai" >/etc/timezone && \
53
- git config --global user.email "qinglong@@users.noreply.github.com" && \
52
+ git config --global user.email "qinglong@users.noreply.github.com" && \
54
53
  git config --global user.name "qinglong" && \
55
54
  git config --global http.postBuffer 524288000 && \
56
55
  npm install -g pnpm@8.3.1 pm2 ts-node && \
57
56
  rm -rf /root/.cache && \
58
57
  rm -rf /root/.npm && \
59
58
  rm -rf /etc/apt/apt.conf.d/docker-clean && \
60
- ulimit -c 0 && \
61
- PYTHON_SHORT_VERSION=$(echo ${PYTHON_VERSION} | cut -d. -f1,2)
59
+ ulimit -c 0
62
60
 
63
61
  ARG SOURCE_COMMIT
64
62
  RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
@@ -75,10 +73,10 @@ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
75
73
  PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
76
74
  PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
77
75
 
78
- ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME} \
76
+ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
79
77
  NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
80
78
  PIP_CACHE_DIR=${PYTHON_HOME}/pip \
81
- PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages:${PYTHONPATH}
79
+ PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
82
80
 
83
81
  RUN pip3 install --prefix ${PYTHON_HOME} requests
84
82
 
package/docker/Dockerfile CHANGED
@@ -18,14 +18,13 @@ ARG QL_MAINTAINER="whyour"
18
18
  LABEL maintainer="${QL_MAINTAINER}"
19
19
  ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
20
20
  ARG QL_BRANCH=develop
21
+ ARG PYTHON_SHORT_VERSION=3.11
21
22
 
22
23
  ENV QL_DIR=/ql \
23
24
  QL_BRANCH=${QL_BRANCH} \
24
25
  LANG=C.UTF-8 \
25
26
  SHELL=/bin/bash \
26
- PS1="\u@\h:\w \$ " \
27
- PYTHONPATH= \
28
- PYTHON_SHORT_VERSION=
27
+ PS1="\u@\h:\w \$ "
29
28
 
30
29
  COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
31
30
  COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
@@ -51,15 +50,14 @@ RUN set -x && \
51
50
  apt-get clean && \
52
51
  ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
53
52
  echo "Asia/Shanghai" >/etc/timezone && \
54
- git config --global user.email "qinglong@@users.noreply.github.com" && \
53
+ git config --global user.email "qinglong@users.noreply.github.com" && \
55
54
  git config --global user.name "qinglong" && \
56
55
  git config --global http.postBuffer 524288000 && \
57
56
  npm install -g pnpm@8.3.1 pm2 ts-node && \
58
57
  rm -rf /root/.cache && \
59
58
  rm -rf /root/.npm && \
60
59
  rm -rf /etc/apt/apt.conf.d/docker-clean && \
61
- ulimit -c 0 && \
62
- PYTHON_SHORT_VERSION=$(echo ${PYTHON_VERSION} | cut -d. -f1,2)
60
+ ulimit -c 0
63
61
 
64
62
  ARG SOURCE_COMMIT
65
63
  RUN git clone --depth=1 -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} && \
@@ -76,10 +74,10 @@ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
76
74
  PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
77
75
  PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
78
76
 
79
- ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME} \
77
+ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
80
78
  NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
81
79
  PIP_CACHE_DIR=${PYTHON_HOME}/pip \
82
- PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages:${PYTHONPATH}
80
+ PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
83
81
 
84
82
  RUN pip3 install --prefix ${PYTHON_HOME} requests
85
83
 
@@ -24,7 +24,7 @@ pm2 l &>/dev/null
24
24
  log_with_style "INFO" "🔄 2. 启动 nginx..."
25
25
  nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
26
26
 
27
- log_with_style "INFO" "⚙️ 3. 启动 pm2 服务...\n"
27
+ log_with_style "INFO" "⚙️ 3. 启动 pm2 服务..."
28
28
  reload_pm2
29
29
 
30
30
  if [[ $AutoStartBot == true ]]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "2.19.0-0",
3
+ "version": "2.19.0-10",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -86,8 +86,7 @@
86
86
  "express-jwt": "^8.4.1",
87
87
  "express-rate-limit": "^7.4.1",
88
88
  "express-urlrewrite": "^2.0.3",
89
- "form-data": "^4.0.0",
90
- "got": "^11.8.2",
89
+ "undici": "^7.9.0",
91
90
  "hpagent": "^1.2.0",
92
91
  "http-proxy-middleware": "^3.0.3",
93
92
  "iconv-lite": "^0.6.3",
package/sample/notify.js CHANGED
@@ -1,7 +1,42 @@
1
1
  const querystring = require('node:querystring');
2
- const got = require('got');
2
+ const { request: undiciRequest, ProxyAgent, FormData } = require('undici');
3
3
  const timeout = 15000;
4
4
 
5
+ async function request(url, options = {}) {
6
+ const { json, form, body, headers = {}, ...rest } = options;
7
+
8
+ const finalHeaders = { ...headers };
9
+ let finalBody = body;
10
+
11
+ if (json) {
12
+ finalHeaders['content-type'] = 'application/json';
13
+ finalBody = JSON.stringify(json);
14
+ } else if (form) {
15
+ finalBody = form;
16
+ delete finalHeaders['content-type'];
17
+ }
18
+
19
+ return undiciRequest(url, {
20
+ headers: finalHeaders,
21
+ body: finalBody,
22
+ ...rest,
23
+ });
24
+ }
25
+
26
+ function post(url, options = {}) {
27
+ return request(url, { ...options, method: 'POST' });
28
+ }
29
+
30
+ function get(url, options = {}) {
31
+ return request(url, { ...options, method: 'GET' });
32
+ }
33
+
34
+ const httpClient = {
35
+ request,
36
+ post,
37
+ get,
38
+ };
39
+
5
40
  const push_config = {
6
41
  HITOKOTO: true, // 启用一言(随机句子)
7
42
 
@@ -123,9 +158,9 @@ for (const key in push_config) {
123
158
  const $ = {
124
159
  post: (params, callback) => {
125
160
  const { url, ...others } = params;
126
- got.post(url, others).then(
127
- (res) => {
128
- let body = res.body;
161
+ httpClient.post(url, others).then(
162
+ async (res) => {
163
+ let body = await res.body.text();
129
164
  try {
130
165
  body = JSON.parse(body);
131
166
  } catch (error) {}
@@ -138,9 +173,9 @@ const $ = {
138
173
  },
139
174
  get: (params, callback) => {
140
175
  const { url, ...others } = params;
141
- got.get(url, others).then(
142
- (res) => {
143
- let body = res.body;
176
+ httpClient.get(url, others).then(
177
+ async (res) => {
178
+ let body = await res.body.text();
144
179
  try {
145
180
  body = JSON.parse(body);
146
181
  } catch (error) {}
@@ -156,8 +191,8 @@ const $ = {
156
191
 
157
192
  async function one() {
158
193
  const url = 'https://v1.hitokoto.cn/';
159
- const res = await got.get(url);
160
- const body = JSON.parse(res.body);
194
+ const res = await httpClient.request(url);
195
+ const body = await res.body.json();
161
196
  return `${body.hitokoto} ----${body.from}`;
162
197
  }
163
198
 
@@ -442,21 +477,11 @@ function tgBotNotify(text, desp) {
442
477
  timeout,
443
478
  };
444
479
  if (TG_PROXY_HOST && TG_PROXY_PORT) {
445
- const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
446
- const _options = {
447
- keepAlive: true,
448
- keepAliveMsecs: 1000,
449
- maxSockets: 256,
450
- maxFreeSockets: 256,
451
- proxy: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
452
- };
453
- const httpAgent = new HttpProxyAgent(_options);
454
- const httpsAgent = new HttpsProxyAgent(_options);
455
- const agent = {
456
- http: httpAgent,
457
- https: httpsAgent,
458
- };
459
- options.agent = agent;
480
+ let agent;
481
+ agent = new ProxyAgent({
482
+ uri: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
483
+ });
484
+ options.dispatcher = agent;
460
485
  }
461
486
  $.post(options, (err, resp, data) => {
462
487
  try {
@@ -1209,17 +1234,18 @@ function webhookNotify(text, desp) {
1209
1234
  '$title',
1210
1235
  encodeURIComponent(text),
1211
1236
  ).replaceAll('$content', encodeURIComponent(desp));
1212
- got(formatUrl, options).then((resp) => {
1237
+ httpClient.request(formatUrl, options).then(async (resp) => {
1238
+ const body = await resp.body.text();
1213
1239
  try {
1214
1240
  if (resp.statusCode !== 200) {
1215
- console.log(`自定义发送通知消息失败😞 ${resp.body}\n`);
1241
+ console.log(`自定义发送通知消息失败😞 ${body}\n`);
1216
1242
  } else {
1217
- console.log(`自定义发送通知消息成功🎉 ${resp.body}\n`);
1243
+ console.log(`自定义发送通知消息成功🎉 ${body}\n`);
1218
1244
  }
1219
1245
  } catch (e) {
1220
1246
  $.logErr(e, resp);
1221
1247
  } finally {
1222
- resolve(resp.body);
1248
+ resolve(body);
1223
1249
  }
1224
1250
  });
1225
1251
  });
@@ -54,7 +54,7 @@ def run():
54
54
 
55
55
  task_before = os.getenv("task_before")
56
56
  if task_before:
57
- escaped_task_before = task_before.replace("'", "'\\''")
57
+ escaped_task_before = task_before.replace('"', '\\"').replace("$", "\\$")
58
58
  commands.append(f"eval '{escaped_task_before}'")
59
59
  print("执行前置命令\n")
60
60
 
package/shell/share.sh CHANGED
@@ -285,7 +285,7 @@ reload_pm2() {
285
285
  cd $dir_root
286
286
  restore_env_vars
287
287
  pm2 flush &>/dev/null
288
- pm2 startOrGracefulReload ecosystem.config.js
288
+ pm2 startOrGracefulReload ecosystem.config.js --update-env
289
289
  }
290
290
 
291
291
  diff_time() {
package/shell/start.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- # 前置依赖 nodejs、npm
3
+ # 前置依赖 nodejs、npm、python3
4
4
  set -e
5
5
  set -x
6
6
 
@@ -34,39 +34,49 @@ fi
34
34
 
35
35
  command="$1"
36
36
 
37
- if [[ $command == "reload" ]]; then
38
- mkdir -p /run/nginx
39
- nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
40
- exit 1
41
- fi
37
+ if [[ $command != "reload" ]]; then
38
+ # 安装依赖
39
+ os_name=$(source /etc/os-release && echo "$ID")
40
+
41
+ if [[ $os_name == 'alpine' ]]; then
42
+ apk update
43
+ apk add -f bash \
44
+ coreutils \
45
+ git \
46
+ curl \
47
+ wget \
48
+ tzdata \
49
+ perl \
50
+ openssl \
51
+ jq \
52
+ nginx \
53
+ openssh \
54
+ procps \
55
+ netcat-openbsd
56
+ elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
57
+ apt-get update
58
+ apt-get install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
59
+ else
60
+ echo -e "暂不支持此系统部署 $os_name"
61
+ exit 1
62
+ fi
42
63
 
43
- # 安装依赖
44
- os_name=$(source /etc/os-release && echo "$ID")
45
-
46
- if [[ $os_name == 'alpine' ]]; then
47
- apk update
48
- apk add -f bash \
49
- coreutils \
50
- git \
51
- curl \
52
- wget \
53
- tzdata \
54
- perl \
55
- openssl \
56
- jq \
57
- nginx \
58
- openssh \
59
- procps \
60
- netcat-openbsd
61
- elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
62
- apt-get update
63
- apt-get install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
64
- else
65
- echo -e "暂不支持此系统部署 $os_name"
66
- exit 1
64
+ npm install -g pnpm@8.3.1 pm2 ts-node
67
65
  fi
68
66
 
69
- npm install -g pnpm@8.3.1 pm2 ts-node
67
+ export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
68
+ export PNPM_HOME=${QL_DIR}/data/dep_cache/node
69
+ export PYTHON_HOME=${QL_DIR}/data/dep_cache/python3
70
+ export PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
71
+
72
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin
73
+ export NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules
74
+ export PIP_CACHE_DIR=${PYTHON_HOME}/pip
75
+ export PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages
76
+
77
+ if [[ $command != "reload" ]]; then
78
+ pip3 install --prefix ${PYTHON_HOME} requests
79
+ fi
70
80
 
71
81
  cd ${QL_DIR}
72
82
  cp -f .env.example .env
@@ -75,7 +85,15 @@ chmod 777 ${QL_DIR}/shell/*.sh
75
85
  . ${QL_DIR}/shell/share.sh
76
86
  . ${QL_DIR}/shell/env.sh
77
87
 
78
- echo -e "======================1. 检测配置文件========================\n"
88
+ log_with_style() {
89
+ local level="$1"
90
+ local message="$2"
91
+ local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
92
+
93
+ printf "\n[%s] [%7s] %s\n" "${timestamp}" "${level}" "${message}"
94
+ }
95
+
96
+ log_with_style "INFO" "🚀 1. 检测配置文件..."
79
97
  import_config "$@"
80
98
  make_dir /etc/nginx/conf.d
81
99
  make_dir /run/nginx
@@ -84,31 +102,25 @@ fix_config
84
102
 
85
103
  pm2 l &>/dev/null
86
104
 
87
- echo -e "======================2. 安装依赖========================\n"
88
- patch_version
89
-
90
- echo -e "======================3. 启动nginx========================\n"
105
+ log_with_style "INFO" "🔄 2. 启动 nginx..."
91
106
  nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
92
- echo -e "nginx启动成功...\n"
93
107
 
94
- reload_update
108
+ log_with_style "INFO" "⚙️ 3. 启动 pm2 服务..."
95
109
  reload_pm2
96
110
 
97
- if [[ $AutoStartBot == true ]]; then
98
- echo -e "======================5. 启动bot========================\n"
99
- nohup ql bot >$dir_log/bot.log 2>&1 &
100
- echo -e "bot后台启动中...\n"
101
- fi
111
+ if [[ $command != "reload" ]]; then
112
+ if [[ $AutoStartBot == true ]]; then
113
+ log_with_style "INFO" "🤖 4. 启动 bot..."
114
+ nohup ql bot >$dir_log/bot.log 2>&1 &
115
+ fi
102
116
 
103
- if [[ $EnableExtraShell == true ]]; then
104
- echo -e "====================6. 执行自定义脚本========================\n"
105
- nohup ql extra >$dir_log/extra.log 2>&1 &
106
- echo -e "自定义脚本后台执行中...\n"
107
- fi
117
+ if [[ $EnableExtraShell == true ]]; then
118
+ log_with_style "INFO" "🛠️ 5. 执行自定义脚本..."
119
+ nohup ql extra >$dir_log/extra.log 2>&1 &
120
+ fi
108
121
 
109
- pm2 startup
110
- pm2 save
122
+ pm2 startup
123
+ pm2 save
124
+ fi
111
125
 
112
- echo -e "############################################################\n"
113
- echo -e "启动完成..."
114
- echo -e "############################################################\n"
126
+ log_with_style "SUCCESS" "🎉 启动成功!"
@@ -29,7 +29,6 @@ exports.default = (app) => {
29
29
  remark: celebrate_1.Joi.string().optional().allow(''),
30
30
  })),
31
31
  }), async (req, res, next) => {
32
- const logger = typedi_1.Container.get('logger');
33
32
  try {
34
33
  const dependenceService = typedi_1.Container.get(dependence_1.default);
35
34
  const data = await dependenceService.create(req.body);
@@ -47,7 +46,6 @@ exports.default = (app) => {
47
46
  remark: celebrate_1.Joi.string().optional().allow(''),
48
47
  }),
49
48
  }), async (req, res, next) => {
50
- const logger = typedi_1.Container.get('logger');
51
49
  try {
52
50
  const dependenceService = typedi_1.Container.get(dependence_1.default);
53
51
  const data = await dependenceService.update(req.body);
@@ -60,7 +58,6 @@ exports.default = (app) => {
60
58
  route.delete('/', (0, celebrate_1.celebrate)({
61
59
  body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
62
60
  }), async (req, res, next) => {
63
- const logger = typedi_1.Container.get('logger');
64
61
  try {
65
62
  const dependenceService = typedi_1.Container.get(dependence_1.default);
66
63
  const data = await dependenceService.remove(req.body);
@@ -73,7 +70,6 @@ exports.default = (app) => {
73
70
  route.delete('/force', (0, celebrate_1.celebrate)({
74
71
  body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
75
72
  }), async (req, res, next) => {
76
- const logger = typedi_1.Container.get('logger');
77
73
  try {
78
74
  const dependenceService = typedi_1.Container.get(dependence_1.default);
79
75
  const data = await dependenceService.remove(req.body, true);
@@ -88,7 +84,6 @@ exports.default = (app) => {
88
84
  id: celebrate_1.Joi.number().required(),
89
85
  }),
90
86
  }), async (req, res, next) => {
91
- const logger = typedi_1.Container.get('logger');
92
87
  try {
93
88
  const dependenceService = typedi_1.Container.get(dependence_1.default);
94
89
  const data = await dependenceService.getDb({ id: req.params.id });
@@ -101,7 +96,6 @@ exports.default = (app) => {
101
96
  route.put('/reinstall', (0, celebrate_1.celebrate)({
102
97
  body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
103
98
  }), async (req, res, next) => {
104
- const logger = typedi_1.Container.get('logger');
105
99
  try {
106
100
  const dependenceService = typedi_1.Container.get(dependence_1.default);
107
101
  const data = await dependenceService.reInstall(req.body);
@@ -47,7 +47,7 @@ exports.default = (app) => {
47
47
  route.get('/:file', async (req, res, next) => {
48
48
  try {
49
49
  const logService = typedi_1.Container.get(log_1.default);
50
- const finalPath = logService.checkFilePath(req.query.path || '', req.query.file || '');
50
+ const finalPath = logService.checkFilePath(req.query.path || '', req.params.file || '');
51
51
  if (!finalPath || blacklist.includes(req.query.path)) {
52
52
  return res.send({
53
53
  code: 403,