@whyour/qinglong 2.18.3-3 → 2.19.0-0
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.
- package/.env.example +7 -9
- package/docker/310.Dockerfile +18 -9
- package/docker/Dockerfile +18 -9
- package/docker/docker-entrypoint.sh +14 -15
- package/docker/front.conf +0 -32
- package/ecosystem.config.js +5 -25
- package/package.json +9 -11
- package/sample/notify.js +5 -3
- package/shell/check.sh +0 -2
- package/shell/preload/sitecustomize.js +38 -15
- package/shell/preload/sitecustomize.py +42 -18
- package/shell/share.sh +23 -75
- package/shell/update.sh +21 -20
- package/static/build/api/health.js +32 -0
- package/static/build/api/index.js +4 -0
- package/static/build/api/log.js +1 -1
- package/static/build/api/script.js +2 -3
- package/static/build/api/system.js +1 -0
- package/static/build/api/update.js +47 -0
- package/static/build/api/user.js +2 -2
- package/static/build/app.js +70 -21
- package/static/build/config/const.js +2 -1
- package/static/build/config/index.js +32 -25
- package/static/build/config/util.js +72 -20
- package/static/build/data/dependence.js +1 -13
- package/static/build/data/notify.js +1 -0
- package/static/build/loaders/app.js +7 -9
- package/static/build/loaders/db.js +1 -3
- package/static/build/loaders/express.js +1 -9
- package/static/build/loaders/initData.js +7 -8
- package/static/build/loaders/initFile.js +0 -1
- package/static/build/loaders/logger.js +34 -15
- package/static/build/middlewares/monitoring.js +56 -0
- package/static/build/schedule/api.js +47 -8
- package/static/build/schedule/client.js +1 -1
- package/static/build/services/cron.js +12 -6
- package/static/build/services/dependence.js +10 -9
- package/static/build/services/grpc.js +97 -0
- package/static/build/services/health.js +74 -0
- package/static/build/services/http.js +67 -0
- package/static/build/services/metrics.js +82 -0
- package/static/build/services/notify.js +2 -2
- package/static/build/services/system.js +8 -1
- package/static/build/services/user.js +11 -4
- package/static/build/shared/pLimit.js +13 -1
- package/static/dist/{2208.03c2cf4a.async.js → 2208.98ccac5f.async.js} +1 -1
- package/static/dist/8826.faecf076.async.js +1 -0
- package/static/dist/8851.cf7e0ebc.async.js +1 -0
- package/static/dist/index.html +2 -2
- package/static/dist/layouts__index.6e23431c.async.js +1 -0
- package/static/dist/{preload_helper.1b1a7a9f.js → preload_helper.67e88ed6.js} +1 -1
- package/static/dist/{src__pages__crontab__index.5eb33581.async.js → src__pages__crontab__index.d6d37f6a.async.js} +1 -1
- package/static/dist/{src__pages__crontab__modal.b20074c2.async.js → src__pages__crontab__modal.dcd053b5.async.js} +1 -1
- package/static/dist/src__pages__dependence__modal.7f588c0b.async.js +1 -0
- package/static/dist/src__pages__env__editNameModal.411043e2.async.js +1 -0
- package/static/dist/{src__pages__env__modal.d923acdb.async.js → src__pages__env__modal.7d952f26.async.js} +1 -1
- package/static/dist/src__pages__error__index.837f4753.async.js +1 -0
- package/static/dist/{src__pages__initialization__index.684197ee.async.js → src__pages__initialization__index.5bd471c5.async.js} +1 -1
- package/static/dist/src__pages__script__editNameModal.32bb2f80.async.js +1 -0
- package/static/dist/src__pages__script__index.53f99bee.async.js +1 -0
- package/static/dist/{src__pages__script__renameModal.09dfb133.async.js → src__pages__script__renameModal.8232c924.async.js} +1 -1
- package/static/dist/{src__pages__script__saveModal.21b81bcc.async.js → src__pages__script__saveModal.8e358e84.async.js} +1 -1
- package/static/dist/{src__pages__script__setting.c6503aaf.async.js → src__pages__script__setting.dcdd7253.async.js} +1 -1
- package/static/dist/{src__pages__setting__appModal.b115baf8.async.js → src__pages__setting__appModal.25adf30e.async.js} +1 -1
- package/static/dist/src__pages__setting__dependence.95dd01e7.async.js +1 -0
- package/static/dist/src__pages__setting__index.3b426f9f.async.js +1 -0
- package/static/dist/src__pages__setting__notification.989e57d6.async.js +1 -0
- package/static/dist/src__pages__setting__security.7623a492.async.js +1 -0
- package/static/dist/src__pages__setting__systemLog.2e8cc7a0.async.js +1 -0
- package/static/dist/src__pages__subscription__modal.46a69195.async.js +1 -0
- package/static/dist/{umi.32588872.js → umi.b7656bb3.js} +1 -1
- package/version.yaml +12 -6
- package/back.d.ts +0 -9
- package/other.config.js +0 -13
- package/static/build/loaders/update.js +0 -79
- package/static/build/public.js +0 -34
- package/static/build/schedule/index.js +0 -52
- package/static/build/update.js +0 -29
- package/static/dist/8826.b3f9fa78.async.js +0 -1
- package/static/dist/8851.a57942be.async.js +0 -1
- package/static/dist/layouts__index.623b87d2.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.1bb8572d.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.115bb8ea.async.js +0 -1
- package/static/dist/src__pages__error__index.a17578c5.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.7d1cc6b4.async.js +0 -1
- package/static/dist/src__pages__script__index.0cd08dcd.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.f3afc194.async.js +0 -1
- package/static/dist/src__pages__setting__index.34ed674c.async.js +0 -1
- package/static/dist/src__pages__setting__notification.b7722a0b.async.js +0 -1
- package/static/dist/src__pages__setting__security.534a5e67.async.js +0 -1
- package/static/dist/src__pages__setting__systemLog.cb8a2174.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.10cd630d.async.js +0 -1
package/shell/share.sh
CHANGED
|
@@ -72,7 +72,17 @@ original_name=(
|
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
init_env() {
|
|
75
|
-
|
|
75
|
+
local pnpm_global_path=$(pnpm root -g 2>/dev/null)
|
|
76
|
+
export NODE_PATH="/usr/local/bin:/usr/local/lib/node_modules${pnpm_global_path:+:${pnpm_global_path}}"
|
|
77
|
+
|
|
78
|
+
# 如果存在 pnpm 全局路径,创建软链接
|
|
79
|
+
if [[ -n "$pnpm_global_path" ]]; then
|
|
80
|
+
# 确保目标目录存在
|
|
81
|
+
mkdir -p "${dir_root}/node_modules"
|
|
82
|
+
# 链接全局模块到项目的 node_modules
|
|
83
|
+
ln -sf "${pnpm_global_path}/"* "${dir_root}/node_modules/" 2>/dev/null || true
|
|
84
|
+
fi
|
|
85
|
+
|
|
76
86
|
export PYTHONUNBUFFERED=1
|
|
77
87
|
}
|
|
78
88
|
|
|
@@ -170,67 +180,47 @@ fix_config() {
|
|
|
170
180
|
make_dir $dir_dep
|
|
171
181
|
|
|
172
182
|
if [[ ! -s $file_config_user ]]; then
|
|
173
|
-
|
|
174
|
-
cp -fv $file_config_sample $file_config_user
|
|
175
|
-
echo
|
|
183
|
+
cp -f $file_config_sample $file_config_user
|
|
176
184
|
fi
|
|
177
185
|
|
|
178
186
|
if [[ ! -f $file_task_before ]]; then
|
|
179
|
-
|
|
180
|
-
cp -fv $file_task_sample $file_task_before
|
|
181
|
-
echo
|
|
187
|
+
cp -f $file_task_sample $file_task_before
|
|
182
188
|
fi
|
|
183
189
|
|
|
184
190
|
if [[ ! -f $file_task_after ]]; then
|
|
185
|
-
|
|
186
|
-
cp -fv $file_task_sample $file_task_after
|
|
187
|
-
echo
|
|
191
|
+
cp -f $file_task_sample $file_task_after
|
|
188
192
|
fi
|
|
189
193
|
|
|
190
194
|
if [[ ! -f $file_extra_shell ]]; then
|
|
191
|
-
|
|
192
|
-
cp -fv $file_extra_sample $file_extra_shell
|
|
193
|
-
echo
|
|
195
|
+
cp -f $file_extra_sample $file_extra_shell
|
|
194
196
|
fi
|
|
195
197
|
|
|
196
198
|
if [[ ! -s $file_notify_py ]]; then
|
|
197
|
-
|
|
198
|
-
cp -fv $file_notify_py_sample $file_notify_py
|
|
199
|
-
echo
|
|
199
|
+
cp -f $file_notify_py_sample $file_notify_py
|
|
200
200
|
fi
|
|
201
201
|
|
|
202
202
|
if [[ ! -s $file_notify_js ]]; then
|
|
203
|
-
|
|
204
|
-
cp -fv $file_notify_js_sample $file_notify_js
|
|
205
|
-
echo
|
|
203
|
+
cp -f $file_notify_js_sample $file_notify_js
|
|
206
204
|
fi
|
|
207
205
|
|
|
208
206
|
if [[ ! -s $file_test_js ]]; then
|
|
209
|
-
cp -
|
|
210
|
-
echo
|
|
207
|
+
cp -f $file_test_js_sample $file_test_js
|
|
211
208
|
fi
|
|
212
209
|
|
|
213
210
|
if [[ ! -s $file_test_py ]]; then
|
|
214
|
-
cp -
|
|
215
|
-
echo
|
|
211
|
+
cp -f $file_test_py_sample $file_test_py
|
|
216
212
|
fi
|
|
217
213
|
|
|
218
214
|
if [[ -s /etc/nginx/conf.d/default.conf ]]; then
|
|
219
|
-
echo -e "检测到默认nginx配置文件,清空...\n"
|
|
220
215
|
cat /dev/null >/etc/nginx/conf.d/default.conf
|
|
221
|
-
echo
|
|
222
216
|
fi
|
|
223
217
|
|
|
224
218
|
if [[ ! -s $dep_notify_js ]]; then
|
|
225
|
-
|
|
226
|
-
cp -fv $file_notify_js_sample $dep_notify_js
|
|
227
|
-
echo
|
|
219
|
+
cp -f $file_notify_js_sample $dep_notify_js
|
|
228
220
|
fi
|
|
229
221
|
|
|
230
222
|
if [[ ! -s $dep_notify_py ]]; then
|
|
231
|
-
|
|
232
|
-
cp -fv $file_notify_py_sample $dep_notify_py
|
|
233
|
-
echo
|
|
223
|
+
cp -f $file_notify_py_sample $dep_notify_py
|
|
234
224
|
fi
|
|
235
225
|
|
|
236
226
|
}
|
|
@@ -298,13 +288,6 @@ reload_pm2() {
|
|
|
298
288
|
pm2 startOrGracefulReload ecosystem.config.js
|
|
299
289
|
}
|
|
300
290
|
|
|
301
|
-
reload_update() {
|
|
302
|
-
cd $dir_root
|
|
303
|
-
restore_env_vars
|
|
304
|
-
pm2 flush &>/dev/null
|
|
305
|
-
pm2 startOrGracefulReload other.config.js
|
|
306
|
-
}
|
|
307
|
-
|
|
308
291
|
diff_time() {
|
|
309
292
|
local format="$1"
|
|
310
293
|
local begin_time="$2"
|
|
@@ -351,44 +334,9 @@ format_timestamp() {
|
|
|
351
334
|
fi
|
|
352
335
|
}
|
|
353
336
|
|
|
354
|
-
patch_version() {
|
|
355
|
-
git config --global pull.rebase false
|
|
356
|
-
|
|
357
|
-
if [[ -f "$dir_root/db/cookie.db" ]]; then
|
|
358
|
-
echo -e "检测到旧的db文件,拷贝为新db...\n"
|
|
359
|
-
mv $dir_root/db/cookie.db $dir_root/db/env.db
|
|
360
|
-
rm -rf $dir_root/db/cookie.db
|
|
361
|
-
echo
|
|
362
|
-
fi
|
|
363
|
-
|
|
364
|
-
if [[ -d "$dir_root/db" ]]; then
|
|
365
|
-
echo -e "检测到旧的db目录,拷贝到data目录...\n"
|
|
366
|
-
cp -rf $dir_root/config $dir_data
|
|
367
|
-
echo
|
|
368
|
-
fi
|
|
369
|
-
|
|
370
|
-
if [[ -d "$dir_root/scripts" ]]; then
|
|
371
|
-
echo -e "检测到旧的scripts目录,拷贝到data目录...\n"
|
|
372
|
-
cp -rf $dir_root/scripts $dir_data
|
|
373
|
-
echo
|
|
374
|
-
fi
|
|
375
|
-
|
|
376
|
-
if [[ -d "$dir_root/log" ]]; then
|
|
377
|
-
echo -e "检测到旧的log目录,拷贝到data目录...\n"
|
|
378
|
-
cp -rf $dir_root/log $dir_data
|
|
379
|
-
echo
|
|
380
|
-
fi
|
|
381
|
-
|
|
382
|
-
if [[ -d "$dir_root/config" ]]; then
|
|
383
|
-
echo -e "检测到旧的config目录,拷贝到data目录...\n"
|
|
384
|
-
cp -rf $dir_root/config $dir_data
|
|
385
|
-
echo
|
|
386
|
-
fi
|
|
387
|
-
}
|
|
388
|
-
|
|
389
337
|
init_nginx() {
|
|
390
|
-
cp -
|
|
391
|
-
cp -
|
|
338
|
+
cp -f $nginx_conf /etc/nginx/nginx.conf
|
|
339
|
+
cp -f $nginx_app_conf /etc/nginx/conf.d/front.conf
|
|
392
340
|
local location_url="/"
|
|
393
341
|
local aliasStr=""
|
|
394
342
|
local rootStr=""
|
package/shell/update.sh
CHANGED
|
@@ -212,20 +212,25 @@ run_extra_shell() {
|
|
|
212
212
|
|
|
213
213
|
## 脚本用法
|
|
214
214
|
usage() {
|
|
215
|
-
echo -e "
|
|
216
|
-
echo -e "1.
|
|
217
|
-
echo -e "2.
|
|
218
|
-
echo -e "3.
|
|
219
|
-
echo -e "4.
|
|
220
|
-
echo -e "5.
|
|
221
|
-
echo -e "6.
|
|
222
|
-
echo -e "7.
|
|
223
|
-
echo -e "8.
|
|
224
|
-
echo -e "9.
|
|
215
|
+
echo -e "$cmd_update 命令使用方法:"
|
|
216
|
+
echo -e "1. $cmd_update update # 更新并重启青龙"
|
|
217
|
+
echo -e "2. $cmd_update extra # 运行自定义脚本"
|
|
218
|
+
echo -e "3. $cmd_update raw <fileurl> # 更新单个脚本文件"
|
|
219
|
+
echo -e "4. $cmd_update repo <repourl> <path> <blacklist> <dependence> <branch> <extensions> # 更新单个仓库的脚本"
|
|
220
|
+
echo -e "5. $cmd_update rmlog <days> # 删除旧日志"
|
|
221
|
+
echo -e "6. $cmd_update bot # 启动tg-bot"
|
|
222
|
+
echo -e "7. $cmd_update check # 检测青龙环境并修复"
|
|
223
|
+
echo -e "8. $cmd_update resetlet # 重置登录错误次数"
|
|
224
|
+
echo -e "9. $cmd_update resettfa # 禁用两步登录"
|
|
225
|
+
echo -e "10. $cmd_update resetpwd # 修改登录密码"
|
|
226
|
+
echo -e "11. $cmd_update resetname # 修改登录用户名"
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
reload_qinglong() {
|
|
230
|
+
echo -e "[reload_qinglong] deleting Triggered at $(date)" >>${dir_log}/reload.log
|
|
231
|
+
sleep 3
|
|
228
232
|
delete_pm2
|
|
233
|
+
echo -e "[reload_qinglong] deleted Triggered at $(date)" >>${dir_log}/reload.log
|
|
229
234
|
|
|
230
235
|
local reload_target="${1}"
|
|
231
236
|
local primary_branch="master"
|
|
@@ -245,8 +250,9 @@ reload_qinglong() {
|
|
|
245
250
|
rm -rf ${dir_data}/*
|
|
246
251
|
mv -f ${dir_tmp}/data/* ${dir_data}/
|
|
247
252
|
fi
|
|
248
|
-
|
|
253
|
+
echo -e "[reload_qinglong] starting Triggered at $(date)" >>${dir_log}/reload.log
|
|
249
254
|
reload_pm2
|
|
255
|
+
echo -e "[reload_qinglong] started Triggered at $(date)\n" >>${dir_log}/reload.log
|
|
250
256
|
}
|
|
251
257
|
|
|
252
258
|
## 更新 qinglong
|
|
@@ -307,15 +313,7 @@ check_update_dep() {
|
|
|
307
313
|
echo -e "更新包下载成功..."
|
|
308
314
|
|
|
309
315
|
if [[ "$needRestart" == 'true' ]]; then
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
rm -rf ${dir_root}/back ${dir_root}/cli ${dir_root}/docker ${dir_root}/sample ${dir_root}/shell ${dir_root}/src
|
|
313
|
-
mv -f ${dir_tmp}/qinglong-${primary_branch}/* ${dir_root}/
|
|
314
|
-
rm -rf $dir_static/*
|
|
315
|
-
mv -f ${dir_tmp}/qinglong-static-${primary_branch}/* ${dir_static}/
|
|
316
|
-
cp -f $file_config_sample $dir_config/config.sample.sh
|
|
317
|
-
|
|
318
|
-
reload_pm2
|
|
316
|
+
reload_qinglong "system"
|
|
319
317
|
fi
|
|
320
318
|
else
|
|
321
319
|
echo -e "\n依赖检测安装失败,请检查网络...\n"
|
|
@@ -546,6 +544,9 @@ main() {
|
|
|
546
544
|
resetpwd)
|
|
547
545
|
eval update_auth_config "\\\"password\\\":\\\"$p2\\\"" "重置密码" $cmd
|
|
548
546
|
;;
|
|
547
|
+
resetname)
|
|
548
|
+
eval update_auth_config "\\\"username\\\":\\\"$p2\\\"" "重置用户名" $cmd
|
|
549
|
+
;;
|
|
549
550
|
*)
|
|
550
551
|
eval echo -e "命令输入错误...\\\n" $cmd
|
|
551
552
|
eval usage $cmd
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const express_1 = require("express");
|
|
7
|
+
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
8
|
+
const health_1 = require("../services/health");
|
|
9
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
10
|
+
const route = (0, express_1.Router)();
|
|
11
|
+
exports.default = (app) => {
|
|
12
|
+
app.use('/', route);
|
|
13
|
+
route.get('/health', async (req, res) => {
|
|
14
|
+
try {
|
|
15
|
+
const healthService = typedi_1.default.get(health_1.HealthService);
|
|
16
|
+
const health = await healthService.check();
|
|
17
|
+
res.status(200).send({
|
|
18
|
+
code: 200,
|
|
19
|
+
data: health,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
logger_1.default.error('Health check failed:', err);
|
|
24
|
+
res.status(500).send({
|
|
25
|
+
code: 500,
|
|
26
|
+
message: 'Health check failed',
|
|
27
|
+
error: err.message,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -14,6 +14,8 @@ const open_1 = __importDefault(require("./open"));
|
|
|
14
14
|
const dependence_1 = __importDefault(require("./dependence"));
|
|
15
15
|
const system_1 = __importDefault(require("./system"));
|
|
16
16
|
const subscription_1 = __importDefault(require("./subscription"));
|
|
17
|
+
const update_1 = __importDefault(require("./update"));
|
|
18
|
+
const health_1 = __importDefault(require("./health"));
|
|
17
19
|
exports.default = () => {
|
|
18
20
|
const app = (0, express_1.Router)();
|
|
19
21
|
(0, user_1.default)(app);
|
|
@@ -26,6 +28,8 @@ exports.default = () => {
|
|
|
26
28
|
(0, dependence_1.default)(app);
|
|
27
29
|
(0, system_1.default)(app);
|
|
28
30
|
(0, subscription_1.default)(app);
|
|
31
|
+
(0, update_1.default)(app);
|
|
32
|
+
(0, health_1.default)(app);
|
|
29
33
|
return app;
|
|
30
34
|
};
|
|
31
35
|
//# sourceMappingURL=index.js.map
|
package/static/build/api/log.js
CHANGED
|
@@ -71,7 +71,7 @@ exports.default = (app) => {
|
|
|
71
71
|
try {
|
|
72
72
|
let { filename, path } = req.body;
|
|
73
73
|
const logService = typedi_1.Container.get(log_1.default);
|
|
74
|
-
const finalPath = logService.checkFilePath(
|
|
74
|
+
const finalPath = logService.checkFilePath(path, filename);
|
|
75
75
|
if (!finalPath || blacklist.includes(path)) {
|
|
76
76
|
return res.send({
|
|
77
77
|
code: 403,
|
|
@@ -32,7 +32,7 @@ const typedi_1 = require("typedi");
|
|
|
32
32
|
const config_1 = __importDefault(require("../config"));
|
|
33
33
|
const fs = __importStar(require("fs/promises"));
|
|
34
34
|
const celebrate_1 = require("celebrate");
|
|
35
|
-
const path_1 =
|
|
35
|
+
const path_1 = require("path");
|
|
36
36
|
const script_1 = __importDefault(require("../services/script"));
|
|
37
37
|
const multer_1 = __importDefault(require("multer"));
|
|
38
38
|
const utils_1 = require("../shared/utils");
|
|
@@ -61,8 +61,7 @@ exports.default = (app) => {
|
|
|
61
61
|
'package-lock.json',
|
|
62
62
|
];
|
|
63
63
|
if (req.query.path) {
|
|
64
|
-
|
|
65
|
-
result = await (0, util_1.readDir)(targetPath, config_1.default.scriptPath, blacklist);
|
|
64
|
+
result = await (0, util_1.readDir)(req.query.path, config_1.default.scriptPath, blacklist);
|
|
66
65
|
}
|
|
67
66
|
else {
|
|
68
67
|
result = await (0, util_1.readDirs)(config_1.default.scriptPath, config_1.default.scriptPath, blacklist, (a, b) => {
|
|
@@ -326,6 +326,7 @@ exports.default = (app) => {
|
|
|
326
326
|
retries: celebrate_1.Joi.number().optional(),
|
|
327
327
|
twoFactorActivated: celebrate_1.Joi.boolean().optional(),
|
|
328
328
|
password: celebrate_1.Joi.string().optional(),
|
|
329
|
+
username: celebrate_1.Joi.string().optional(),
|
|
329
330
|
}),
|
|
330
331
|
}), async (req, res, next) => {
|
|
331
332
|
try {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const express_1 = require("express");
|
|
7
|
+
const typedi_1 = __importDefault(require("typedi"));
|
|
8
|
+
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
9
|
+
const system_1 = __importDefault(require("../services/system"));
|
|
10
|
+
const route = (0, express_1.Router)();
|
|
11
|
+
exports.default = (app) => {
|
|
12
|
+
app.use('/update', route);
|
|
13
|
+
route.put('/reload', async (req, res, next) => {
|
|
14
|
+
try {
|
|
15
|
+
const systemService = typedi_1.default.get(system_1.default);
|
|
16
|
+
const result = await systemService.reloadSystem();
|
|
17
|
+
res.send(result);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
logger_1.default.error('🔥 error: %o', e);
|
|
21
|
+
return next(e);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
route.put('/system', async (req, res, next) => {
|
|
25
|
+
try {
|
|
26
|
+
const systemService = typedi_1.default.get(system_1.default);
|
|
27
|
+
const result = await systemService.reloadSystem('system');
|
|
28
|
+
res.send(result);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
logger_1.default.error('🔥 error: %o', e);
|
|
32
|
+
return next(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
route.put('/data', async (req, res, next) => {
|
|
36
|
+
try {
|
|
37
|
+
const systemService = typedi_1.default.get(system_1.default);
|
|
38
|
+
const result = await systemService.reloadSystem('data');
|
|
39
|
+
res.send(result);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
logger_1.default.error('🔥 error: %o', e);
|
|
43
|
+
return next(e);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=update.js.map
|
package/static/build/api/user.js
CHANGED
|
@@ -12,6 +12,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const uuid_1 = require("uuid");
|
|
13
13
|
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
|
|
14
14
|
const config_1 = __importDefault(require("../config"));
|
|
15
|
+
const util_1 = require("../config/util");
|
|
15
16
|
const route = (0, express_1.Router)();
|
|
16
17
|
const storage = multer_1.default.diskStorage({
|
|
17
18
|
destination: function (req, file, cb) {
|
|
@@ -62,9 +63,8 @@ exports.default = (app) => {
|
|
|
62
63
|
password: celebrate_1.Joi.string().required(),
|
|
63
64
|
}),
|
|
64
65
|
}), async (req, res, next) => {
|
|
65
|
-
const logger = typedi_1.Container.get('logger');
|
|
66
66
|
try {
|
|
67
|
-
if (
|
|
67
|
+
if ((0, util_1.isDemoEnv)()) {
|
|
68
68
|
return res.send({ code: 450, message: '未知错误' });
|
|
69
69
|
}
|
|
70
70
|
const userService = typedi_1.Container.get(user_1.default);
|
package/static/build/app.js
CHANGED
|
@@ -3,29 +3,78 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
require("reflect-metadata");
|
|
7
|
-
const
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
const compression_1 = __importDefault(require("compression"));
|
|
8
|
+
const cors_1 = __importDefault(require("cors"));
|
|
8
9
|
const express_1 = __importDefault(require("express"));
|
|
10
|
+
const helmet_1 = __importDefault(require("helmet"));
|
|
11
|
+
const typedi_1 = require("typedi");
|
|
12
|
+
const config_1 = __importDefault(require("./config"));
|
|
9
13
|
const logger_1 = __importDefault(require("./loaders/logger"));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
14
|
+
const monitoring_1 = require("./middlewares/monitoring");
|
|
15
|
+
const grpc_1 = require("./services/grpc");
|
|
16
|
+
const http_1 = require("./services/http");
|
|
17
|
+
class Application {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.isShuttingDown = false;
|
|
20
|
+
this.app = (0, express_1.default)();
|
|
21
|
+
this.httpServerService = typedi_1.Container.get(http_1.HttpServerService);
|
|
22
|
+
this.grpcServerService = typedi_1.Container.get(grpc_1.GrpcServerService);
|
|
23
|
+
}
|
|
24
|
+
async start() {
|
|
17
25
|
var _a;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
try {
|
|
27
|
+
await this.initializeDatabase();
|
|
28
|
+
this.setupMiddlewares();
|
|
29
|
+
await this.initializeServices();
|
|
30
|
+
this.setupGracefulShutdown();
|
|
31
|
+
(_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
logger_1.default.error('Failed to start application:', error);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async initializeDatabase() {
|
|
39
|
+
await require('./loaders/db').default();
|
|
40
|
+
}
|
|
41
|
+
setupMiddlewares() {
|
|
42
|
+
this.app.use((0, helmet_1.default)());
|
|
43
|
+
this.app.use((0, cors_1.default)(config_1.default.cors));
|
|
44
|
+
this.app.use((0, compression_1.default)());
|
|
45
|
+
this.app.use(monitoring_1.monitoringMiddleware);
|
|
46
|
+
}
|
|
47
|
+
async initializeServices() {
|
|
48
|
+
await this.grpcServerService.initialize();
|
|
49
|
+
await require('./loaders/app').default({ app: this.app });
|
|
50
|
+
this.server = await this.httpServerService.initialize(this.app, config_1.default.port);
|
|
51
|
+
await require('./loaders/server').default({ server: this.server });
|
|
52
|
+
}
|
|
53
|
+
setupGracefulShutdown() {
|
|
54
|
+
const shutdown = async () => {
|
|
55
|
+
if (this.isShuttingDown)
|
|
56
|
+
return;
|
|
57
|
+
this.isShuttingDown = true;
|
|
58
|
+
logger_1.default.info('Shutting down services...');
|
|
59
|
+
try {
|
|
60
|
+
await Promise.all([
|
|
61
|
+
this.grpcServerService.shutdown(),
|
|
62
|
+
this.httpServerService.shutdown(),
|
|
63
|
+
]);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
logger_1.default.error('Error during shutdown:', error);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
process.on('SIGTERM', shutdown);
|
|
72
|
+
process.on('SIGINT', shutdown);
|
|
73
|
+
}
|
|
29
74
|
}
|
|
30
|
-
|
|
75
|
+
const app = new Application();
|
|
76
|
+
app.start().catch((error) => {
|
|
77
|
+
logger_1.default.error('Application failed to start:', error);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
});
|
|
31
80
|
//# sourceMappingURL=app.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LINUX_DEPENDENCE_COMMAND = exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
|
|
3
|
+
exports.LINUX_DEPENDENCE_COMMAND = exports.PYTHON_INSTALL_DIR = exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
|
|
4
4
|
exports.LOG_END_SYMBOL = ' ';
|
|
5
5
|
exports.TASK_COMMAND = 'task';
|
|
6
6
|
exports.QL_COMMAND = 'ql';
|
|
@@ -23,6 +23,7 @@ exports.SAMPLE_FILES = [
|
|
|
23
23
|
target: 'data/scripts/notify.py',
|
|
24
24
|
},
|
|
25
25
|
];
|
|
26
|
+
exports.PYTHON_INSTALL_DIR = process.env.PYTHON_HOME;
|
|
26
27
|
exports.LINUX_DEPENDENCE_COMMAND = {
|
|
27
28
|
Debian: {
|
|
28
29
|
install: 'apt-get install -y',
|
|
@@ -6,11 +6,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const share_1 = require("./share");
|
|
9
|
+
dotenv_1.default.config({
|
|
10
|
+
path: path_1.default.join(__dirname, '../../.env'),
|
|
11
|
+
});
|
|
12
|
+
const config = {
|
|
13
|
+
port: parseInt(process.env.BACK_PORT || '5600', 10),
|
|
14
|
+
grpcPort: parseInt(process.env.GRPC_PORT || '5500', 10),
|
|
15
|
+
nodeEnv: process.env.NODE_ENV || 'development',
|
|
16
|
+
isDevelopment: process.env.NODE_ENV === 'development',
|
|
17
|
+
isProduction: process.env.NODE_ENV === 'production',
|
|
18
|
+
logs: {
|
|
19
|
+
level: process.env.LOG_LEVEL || 'silly',
|
|
20
|
+
},
|
|
21
|
+
api: {
|
|
22
|
+
prefix: '/api',
|
|
23
|
+
},
|
|
24
|
+
jwt: {
|
|
25
|
+
secret: process.env.JWT_SECRET || (0, share_1.createRandomString)(16, 32),
|
|
26
|
+
expiresIn: process.env.JWT_EXPIRES_IN,
|
|
27
|
+
},
|
|
28
|
+
cors: {
|
|
29
|
+
origin: process.env.CORS_ORIGIN
|
|
30
|
+
? process.env.CORS_ORIGIN.split(',')
|
|
31
|
+
: ['*'],
|
|
32
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
9
35
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
10
36
|
if (!process.env.QL_DIR) {
|
|
11
|
-
// 声明QL_DIR环境变量
|
|
12
37
|
let qlHomePath = path_1.default.join(__dirname, '../../');
|
|
13
|
-
// 生产环境
|
|
14
38
|
if (qlHomePath.endsWith('/static/')) {
|
|
15
39
|
qlHomePath = path_1.default.join(qlHomePath, '../');
|
|
16
40
|
}
|
|
@@ -58,19 +82,7 @@ const dependenceProxyFile = path_1.default.join(configPath, 'dependence-proxy.sh
|
|
|
58
82
|
if (envFound.error) {
|
|
59
83
|
throw new Error("⚠️ Couldn't find .env file ⚠️");
|
|
60
84
|
}
|
|
61
|
-
exports.default = {
|
|
62
|
-
port: parseInt(process.env.BACK_PORT, 10),
|
|
63
|
-
cronPort: parseInt(process.env.CRON_PORT, 10),
|
|
64
|
-
publicPort: parseInt(process.env.PUBLIC_PORT, 10),
|
|
65
|
-
updatePort: parseInt(process.env.UPDATE_PORT, 10),
|
|
66
|
-
secret: process.env.SECRET || (0, share_1.createRandomString)(16, 32),
|
|
67
|
-
logs: {
|
|
68
|
-
level: process.env.LOG_LEVEL || 'silly',
|
|
69
|
-
},
|
|
70
|
-
api: {
|
|
71
|
-
prefix: '/api',
|
|
72
|
-
},
|
|
73
|
-
rootPath,
|
|
85
|
+
exports.default = Object.assign(Object.assign({}, config), { jwt: config.jwt, rootPath,
|
|
74
86
|
tmpPath,
|
|
75
87
|
dataPath,
|
|
76
88
|
dataTgzFile,
|
|
@@ -96,8 +108,7 @@ exports.default = {
|
|
|
96
108
|
configPath,
|
|
97
109
|
scriptPath,
|
|
98
110
|
repoPath,
|
|
99
|
-
samplePath,
|
|
100
|
-
blackFileList: [
|
|
111
|
+
samplePath, blackFileList: [
|
|
101
112
|
'auth.json',
|
|
102
113
|
'config.sh.sample',
|
|
103
114
|
'cookie.sh',
|
|
@@ -107,11 +118,9 @@ exports.default = {
|
|
|
107
118
|
'env.js',
|
|
108
119
|
'env.py',
|
|
109
120
|
'token.json',
|
|
110
|
-
],
|
|
111
|
-
writePathList: [configPath, scriptPath],
|
|
112
|
-
bakPath,
|
|
113
|
-
apiWhiteList: [
|
|
121
|
+
], writePathList: [configPath, scriptPath], bakPath, apiWhiteList: [
|
|
114
122
|
'/api/user/login',
|
|
123
|
+
'/api/health',
|
|
115
124
|
'/open/auth/token',
|
|
116
125
|
'/api/user/two-factor/login',
|
|
117
126
|
'/api/system',
|
|
@@ -122,11 +131,9 @@ exports.default = {
|
|
|
122
131
|
'/open/system',
|
|
123
132
|
'/open/user/init',
|
|
124
133
|
'/open/user/notification/init',
|
|
125
|
-
],
|
|
126
|
-
versionFile,
|
|
134
|
+
], versionFile,
|
|
127
135
|
lastVersionFile,
|
|
128
136
|
sqliteFile,
|
|
129
137
|
sshdPath,
|
|
130
|
-
systemLogPath
|
|
131
|
-
};
|
|
138
|
+
systemLogPath });
|
|
132
139
|
//# sourceMappingURL=index.js.map
|