@whyour/qinglong 2.21.0-8 → 2.22.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/.dockerignore +13 -0
- package/.env.example +7 -0
- package/AGENTS.md +2 -2
- package/README-en.md +24 -0
- package/README.md +24 -0
- package/back/protos/api.proto +6 -1
- package/back/protos/cron.proto +4 -1
- package/docker/Dockerfile +31 -12
- package/docker/Dockerfile.310 +31 -12
- package/docker/Dockerfile.debian +22 -14
- package/docker/Dockerfile.debian310 +24 -14
- package/docker/build-manifest.cjs +28 -0
- package/docker/verify-build.cjs +49 -0
- package/docs/releases/2.22.0-validation.md +49 -0
- package/docs/releases/2.22.0.md +54 -0
- package/ecosystem.config.js +10 -1
- package/package.json +11 -6
- package/sample/config.sample.sh +10 -0
- package/sample/notify.js +54 -0
- package/sample/notify.py +37 -0
- package/scripts/benchmark-execution.cjs +96 -0
- package/scripts/write-build-info.cjs +27 -0
- package/shell/api.sh +34 -13
- package/shell/check.sh +59 -19
- package/shell/lang/en.sh +6 -0
- package/shell/lang/zh.sh +6 -0
- package/shell/node_path_cache.sh +128 -0
- package/shell/otask.sh +7 -1
- package/shell/preload/sitecustomize.js +5 -1
- package/shell/share.sh +25 -8
- package/shell/start.sh +6 -3
- package/shell/task.sh +13 -3
- package/shell/update.sh +65 -4
- package/static/build/api/clientIp.js +42 -0
- package/static/build/api/config.js +8 -16
- package/static/build/api/cron.js +38 -2
- package/static/build/api/dashboard.js +37 -0
- package/static/build/api/health.js +2 -2
- package/static/build/api/index.js +4 -0
- package/static/build/api/log.js +30 -19
- package/static/build/api/retention.js +63 -0
- package/static/build/api/script.js +23 -22
- package/static/build/api/subscription.js +16 -2
- package/static/build/api/system.js +25 -2
- package/static/build/api/user.js +75 -15
- package/static/build/app.js +54 -45
- package/static/build/bootstrap/database.js +51 -0
- package/static/build/config/const.js +1 -0
- package/static/build/config/share.js +5 -4
- package/static/build/config/util.js +133 -38
- package/static/build/data/cron.js +1 -0
- package/static/build/data/notify.js +11 -1
- package/static/build/loaders/app.js +2 -0
- package/static/build/loaders/db.js +3 -33
- package/static/build/loaders/deps.js +29 -0
- package/static/build/loaders/express.js +30 -21
- package/static/build/loaders/initData.js +10 -7
- package/static/build/loaders/sock.js +72 -6
- package/static/build/middlewares/monitoring.js +12 -33
- package/static/build/middlewares/protectedPathCase.js +17 -0
- package/static/build/protos/api.js +56 -2
- package/static/build/protos/cron.js +21 -4
- package/static/build/protos/health.js +1 -1
- package/static/build/schedule/addCron.js +9 -0
- package/static/build/schedule/api.js +5 -2
- package/static/build/schedule/client.js +38 -6
- package/static/build/schedule/health.js +72 -7
- package/static/build/services/config.js +5 -42
- package/static/build/services/cron.js +338 -199
- package/static/build/services/dependence.js +47 -0
- package/static/build/services/grpc.js +1 -1
- package/static/build/services/health.js +4 -7
- package/static/build/services/http.js +8 -2
- package/static/build/services/log.js +2 -3
- package/static/build/services/metrics.js +46 -14
- package/static/build/services/notify.js +26 -0
- package/static/build/services/retention.js +123 -0
- package/static/build/services/schedule.js +57 -33
- package/static/build/services/script.js +4 -5
- package/static/build/services/subscription.js +55 -34
- package/static/build/services/system.js +37 -9
- package/static/build/services/user.js +213 -25
- package/static/build/shared/auth.js +18 -5
- package/static/build/shared/authMutation.js +17 -0
- package/static/build/shared/childProcess.js +82 -0
- package/static/build/shared/clientIp.js +27 -0
- package/static/build/shared/errors.js +9 -0
- package/static/build/shared/fileAccess.js +60 -0
- package/static/build/shared/i18n.js +12 -5
- package/static/build/shared/logReader.js +85 -0
- package/static/build/shared/logStreamManager.js +80 -60
- package/static/build/shared/password.js +30 -0
- package/static/build/shared/retention.js +58 -0
- package/static/build/shared/runCron.js +28 -15
- package/static/build/shared/schedulerMutationLock.js +44 -0
- package/static/build/shared/schedulerReadiness.js +82 -0
- package/static/build/shared/schemaMigrations.js +58 -0
- package/static/build/shared/startupProcess.js +48 -0
- package/static/build/shared/store.js +7 -0
- package/static/build/shared/trustProxy.js +119 -0
- package/static/build/validation/schedule.js +3 -3
- package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
- package/static/dist/2031.6af40025.async.js +1 -0
- package/static/dist/2693.51c2636b.async.js +1 -0
- package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
- package/static/dist/2901.2ca95295.async.js +1 -0
- package/static/dist/445.a65ff63b.async.js +1 -0
- package/static/dist/4736.1d2b5cb6.async.js +1 -0
- package/static/dist/{4859.6592cebb.async.js → 4859.97d6653c.async.js} +1 -1
- package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
- package/static/dist/6212.9e6d9913.async.js +1 -0
- package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
- package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
- package/static/dist/7231.f7e5b668.async.js +1 -0
- package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
- package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
- package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
- package/static/dist/8844.a0fef08e.async.js +1 -0
- package/static/dist/index.html +2 -2
- package/static/dist/layouts__index.633d3553.async.js +1 -0
- package/static/dist/preload_helper.cf7de3fa.js +1 -0
- package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
- package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
- package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
- package/static/dist/{src__pages__crontab__logModal.831d5e4b.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
- package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
- package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
- package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
- package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
- package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
- package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
- package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
- package/static/dist/src__pages__dependence__modal.a29c1a0f.async.js +1 -0
- package/static/dist/{src__pages__diff__index.013b7c75.async.js → src__pages__diff__index.1714b941.async.js} +1 -1
- package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
- package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
- package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
- package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
- package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
- package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
- package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
- package/static/dist/src__pages__script__editModal.22acdf7c.async.js +1 -0
- package/static/dist/src__pages__script__editNameModal.1a521cc0.async.js +1 -0
- package/static/dist/src__pages__script__index.a18b2692.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
- package/static/dist/src__pages__script__saveModal.8965b74c.async.js +1 -0
- package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
- package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
- package/static/dist/{src__pages__setting__checkUpdate.34d773f2.async.js → src__pages__setting__checkUpdate.d175b154.async.js} +1 -1
- package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
- package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
- package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
- package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
- package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
- package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
- package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
- package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
- package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
- package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
- package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
- package/static/dist/src__pages__subscription__modal.38991e1e.async.js +1 -0
- package/static/dist/{umi.a54a59f6.js → umi.fc019050.js} +1 -1
- package/test/back/auth-security.test.cjs +74 -0
- package/test/back/build-provenance.test.cjs +150 -0
- package/test/back/cron-log-name.test.cjs +110 -0
- package/test/back/cron-validation.test.cjs +45 -0
- package/test/back/dashboard-failures.test.cjs +173 -0
- package/test/back/database-bootstrap.test.cjs +193 -0
- package/test/back/dependence-cache-status.test.cjs +125 -0
- package/test/back/deprecated-file-routes.test.cjs +82 -0
- package/test/back/ecosystem.test.cjs +28 -0
- package/test/back/env-name-parsing.test.cjs +96 -0
- package/test/back/execution-lifecycle.test.cjs +236 -0
- package/test/back/file-access-security.test.cjs +47 -0
- package/test/back/fileTreeListing.test.cjs +57 -0
- package/test/back/grpc-cron-response.test.cjs +60 -0
- package/test/back/http-exclusive-listen.test.cjs +31 -0
- package/test/back/http-security.test.cjs +213 -0
- package/test/back/listen-security.test.cjs +67 -0
- package/test/back/log-path-security.test.cjs +158 -0
- package/test/back/logReader.test.cjs +72 -0
- package/test/back/manual-execution.test.cjs +85 -0
- package/test/back/manual-stop-claim.test.cjs +220 -0
- package/test/back/metrics.test.cjs +34 -0
- package/test/back/monitoring.test.cjs +73 -0
- package/test/back/node-path-cache.test.cjs +173 -0
- package/test/back/node-path-lock.test.cjs +178 -0
- package/test/back/npm-publication.test.cjs +70 -0
- package/test/back/primary-apm.test.cjs +24 -0
- package/test/back/process-exit-state.test.cjs +81 -0
- package/test/back/process-stop-signal.test.cjs +77 -0
- package/test/back/protected-path-case.test.cjs +58 -0
- package/test/back/qlServiceLogCommand.test.cjs +128 -0
- package/test/back/retention.test.cjs +131 -0
- package/test/back/role-loading.test.cjs +118 -0
- package/test/back/schedule-health.test.cjs +86 -0
- package/test/back/scheduler-file-lock.test.cjs +51 -0
- package/test/back/scheduler-mutation.test.cjs +312 -0
- package/test/back/scheduler-readiness.test.cjs +85 -0
- package/test/back/scheduler-reconciliation.test.cjs +152 -0
- package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
- package/test/back/schema-migrations.test.cjs +127 -0
- package/test/back/shell-api-parsing.test.cjs +184 -0
- package/test/back/sock-polling.test.cjs +297 -0
- package/test/back/sock-security.test.cjs +72 -0
- package/test/back/start-env-preservation.test.cjs +53 -0
- package/test/back/stop-failure-feedback.test.cjs +158 -0
- package/test/back/stop-race.test.cjs +167 -0
- package/test/back/subscription-cleanup.test.cjs +53 -0
- package/test/back/subscription-stop-state.test.cjs +66 -0
- package/test/back/system-dependence-cache.test.cjs +126 -0
- package/test/back/task-time.test.cjs +116 -0
- package/test/back/user-api.test.cjs +99 -0
- package/test/back/user-security.test.cjs +248 -0
- package/test/back/worker-apm.test.cjs +84 -0
- package/test/back/wpush-grpc.test.cjs +115 -0
- package/test/front/cron-log-pagination.test.cjs +214 -0
- package/test/front/http-auth.test.cjs +152 -0
- package/test/front/http-error.test.cjs +29 -0
- package/test/helpers/load-security-module.cjs +42 -0
- package/version.yaml +19 -34
- package/CLAUDE.md +0 -43
- package/static/dist/1147.62793604.async.js +0 -1
- package/static/dist/134.54df9e38.async.js +0 -1
- package/static/dist/2208.85285476.async.js +0 -1
- package/static/dist/2286.f371c743.async.js +0 -1
- package/static/dist/3191.545ab873.async.js +0 -1
- package/static/dist/4902.555f92ab.async.js +0 -1
- package/static/dist/5520.ff2cfd6b.async.js +0 -1
- package/static/dist/6431.c50479be.async.js +0 -1
- package/static/dist/8826.db34ad8d.async.js +0 -1
- package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
- package/static/dist/preload_helper.3048fe5b.js +0 -1
- package/static/dist/src__pages__crontab__detail.b98f0084.async.js +0 -1
- package/static/dist/src__pages__crontab__index.68e78a33.async.js +0 -1
- package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
- package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
- package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
- package/static/dist/src__pages__dashboard__index.58177357.async.js +0 -1
- package/static/dist/src__pages__dependence__index.b7bbc795.async.js +0 -1
- package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.f7bb47ba.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.48715576.async.js +0 -1
- package/static/dist/src__pages__env__index.452cdc47.async.js +0 -1
- package/static/dist/src__pages__env__modal.e1234834.async.js +0 -1
- package/static/dist/src__pages__error__index.dedb2b90.async.js +0 -1
- package/static/dist/src__pages__initialization__index.22620a77.async.js +0 -1
- package/static/dist/src__pages__log__index.9c66639f.async.js +0 -1
- package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.532a3044.async.js +0 -1
- package/static/dist/src__pages__script__index.1fc20f22.async.js +0 -1
- package/static/dist/src__pages__script__renameModal.5cdde919.async.js +0 -1
- package/static/dist/src__pages__script__saveModal.5ffed35f.async.js +0 -1
- package/static/dist/src__pages__script__setting.1a82c6d7.async.js +0 -1
- package/static/dist/src__pages__setting__appModal.43b7758a.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.9c04c79a.async.js +0 -1
- package/static/dist/src__pages__setting__index.7e070838.async.js +0 -1
- package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
- package/static/dist/src__pages__setting__notification.bac481c2.async.js +0 -1
- package/static/dist/src__pages__setting__other.707cfafe.async.js +0 -1
- package/static/dist/src__pages__setting__security.b7235753.async.js +0 -1
- package/static/dist/src__pages__setting__systemLog.b81a8c1d.async.js +0 -1
- package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
- package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.562448e2.async.js +0 -1
|
@@ -3,28 +3,26 @@ 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
|
-
exports.
|
|
6
|
+
exports.monitoringMiddleware = void 0;
|
|
7
7
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
8
8
|
const perf_hooks_1 = require("perf_hooks");
|
|
9
9
|
const metrics_1 = require("../services/metrics");
|
|
10
|
-
const
|
|
10
|
+
const UNMONITORED_PATH_SUFFIXES = ['/api/health', '/open/health'];
|
|
11
|
+
const HTTP_METRIC_SAMPLE_INTERVAL = 10;
|
|
12
|
+
let requestSampleOffset = 0;
|
|
11
13
|
const monitoringMiddleware = (req, res, next) => {
|
|
14
|
+
if (UNMONITORED_PATH_SUFFIXES.some((path) => req.path.endsWith(path))) {
|
|
15
|
+
return next();
|
|
16
|
+
}
|
|
12
17
|
const start = perf_hooks_1.performance.now();
|
|
13
18
|
const originalEnd = res.end;
|
|
14
19
|
res.end = function (chunk, encoding, cb) {
|
|
15
20
|
const duration = perf_hooks_1.performance.now() - start;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
statusCode: res.statusCode,
|
|
21
|
-
timestamp: Date.now(),
|
|
22
|
-
platform: req.platform,
|
|
23
|
-
};
|
|
24
|
-
requestMetrics.push(metric);
|
|
25
|
-
metrics_1.metricsService.record('http_request', duration, Object.assign({ method: req.method, path: req.path, statusCode: res.statusCode.toString() }, (req.platform && { platform: req.platform })));
|
|
26
|
-
if (requestMetrics.length > 1000) {
|
|
27
|
-
requestMetrics.shift();
|
|
21
|
+
const shouldSample = requestSampleOffset === 0;
|
|
22
|
+
requestSampleOffset =
|
|
23
|
+
(requestSampleOffset + 1) % HTTP_METRIC_SAMPLE_INTERVAL;
|
|
24
|
+
if (shouldSample) {
|
|
25
|
+
metrics_1.metricsService.record('http_request', duration, Object.assign({ method: req.method, path: req.path, statusCode: res.statusCode.toString() }, (req.platform && { platform: req.platform })));
|
|
28
26
|
}
|
|
29
27
|
if (duration > 1000) {
|
|
30
28
|
logger_1.default.warn(`Slow request detected: ${req.method} ${req.path} took ${duration.toFixed(2)}ms`);
|
|
@@ -34,23 +32,4 @@ const monitoringMiddleware = (req, res, next) => {
|
|
|
34
32
|
next();
|
|
35
33
|
};
|
|
36
34
|
exports.monitoringMiddleware = monitoringMiddleware;
|
|
37
|
-
const getMetrics = () => {
|
|
38
|
-
return {
|
|
39
|
-
totalRequests: requestMetrics.length,
|
|
40
|
-
averageDuration: requestMetrics.reduce((acc, curr) => acc + curr.duration, 0) /
|
|
41
|
-
requestMetrics.length,
|
|
42
|
-
requestsByMethod: requestMetrics.reduce((acc, curr) => {
|
|
43
|
-
acc[curr.method] = (acc[curr.method] || 0) + 1;
|
|
44
|
-
return acc;
|
|
45
|
-
}, {}),
|
|
46
|
-
requestsByPlatform: requestMetrics.reduce((acc, curr) => {
|
|
47
|
-
if (curr.platform) {
|
|
48
|
-
acc[curr.platform] = (acc[curr.platform] || 0) + 1;
|
|
49
|
-
}
|
|
50
|
-
return acc;
|
|
51
|
-
}, {}),
|
|
52
|
-
recentRequests: requestMetrics.slice(-10),
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
exports.getMetrics = getMetrics;
|
|
56
35
|
//# sourceMappingURL=monitoring.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function protectedPathCase(req, res, next) {
|
|
4
|
+
const originalPath = req.path;
|
|
5
|
+
const normalizedPath = originalPath.toLowerCase();
|
|
6
|
+
if (originalPath !== normalizedPath &&
|
|
7
|
+
(normalizedPath.startsWith('/api/') ||
|
|
8
|
+
normalizedPath.startsWith('/open/'))) {
|
|
9
|
+
return res.status(400).json({
|
|
10
|
+
code: 400,
|
|
11
|
+
message: 'Invalid path format',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return next();
|
|
15
|
+
}
|
|
16
|
+
exports.default = protectedPathCase;
|
|
17
|
+
//# sourceMappingURL=protectedPathCase.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
4
|
// protoc-gen-ts_proto v2.6.1
|
|
5
|
-
// protoc v3.
|
|
5
|
+
// protoc v3.17.3
|
|
6
6
|
// source: back/protos/api.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.ApiClient = exports.ApiService = exports.SystemNotifyRequest = exports.NotificationInfo = exports.CronDetailResponse = exports.CronDetailRequest = exports.CronResponse = exports.CronsResponse = exports.RunCronsRequest = exports.DisableCronsRequest = exports.EnableCronsRequest = exports.GetCronByIdRequest = exports.GetCronsRequest = exports.DeleteCronsRequest = exports.UpdateCronRequest = exports.CreateCronRequest = exports.CronItem = exports.ExtraScheduleItem = exports.Response = exports.EnvResponse = exports.EnvsResponse = exports.GetEnvByIdRequest = exports.UpdateEnvNamesRequest = exports.EnableEnvsRequest = exports.DisableEnvsRequest = exports.MoveEnvRequest = exports.DeleteEnvsRequest = exports.UpdateEnvRequest = exports.CreateEnvRequest = exports.GetEnvsRequest = exports.EnvItem = exports.notificationModeToJSON = exports.notificationModeFromJSON = exports.NotificationMode = exports.protobufPackage = void 0;
|
|
@@ -34,6 +34,7 @@ var NotificationMode;
|
|
|
34
34
|
NotificationMode[NotificationMode["ntfy"] = 19] = "ntfy";
|
|
35
35
|
NotificationMode[NotificationMode["wxPusherBot"] = 20] = "wxPusherBot";
|
|
36
36
|
NotificationMode[NotificationMode["wxPusherSpt"] = 21] = "wxPusherSpt";
|
|
37
|
+
NotificationMode[NotificationMode["wpush"] = 22] = "wpush";
|
|
37
38
|
NotificationMode[NotificationMode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
38
39
|
})(NotificationMode || (exports.NotificationMode = NotificationMode = {}));
|
|
39
40
|
function notificationModeFromJSON(object) {
|
|
@@ -104,6 +105,9 @@ function notificationModeFromJSON(object) {
|
|
|
104
105
|
case 21:
|
|
105
106
|
case "wxPusherSpt":
|
|
106
107
|
return NotificationMode.wxPusherSpt;
|
|
108
|
+
case 22:
|
|
109
|
+
case "wpush":
|
|
110
|
+
return NotificationMode.wpush;
|
|
107
111
|
case -1:
|
|
108
112
|
case "UNRECOGNIZED":
|
|
109
113
|
default:
|
|
@@ -157,6 +161,8 @@ function notificationModeToJSON(object) {
|
|
|
157
161
|
return "wxPusherBot";
|
|
158
162
|
case NotificationMode.wxPusherSpt:
|
|
159
163
|
return "wxPusherSpt";
|
|
164
|
+
case NotificationMode.wpush:
|
|
165
|
+
return "wpush";
|
|
160
166
|
case NotificationMode.UNRECOGNIZED:
|
|
161
167
|
default:
|
|
162
168
|
return "UNRECOGNIZED";
|
|
@@ -2502,6 +2508,9 @@ function createBaseNotificationInfo() {
|
|
|
2502
2508
|
wxPusherBotTopicIds: undefined,
|
|
2503
2509
|
wxPusherBotUids: undefined,
|
|
2504
2510
|
wxPusherSptList: undefined,
|
|
2511
|
+
wpushApiKey: undefined,
|
|
2512
|
+
wpushChannel: undefined,
|
|
2513
|
+
wpushTopicCode: undefined,
|
|
2505
2514
|
};
|
|
2506
2515
|
}
|
|
2507
2516
|
exports.NotificationInfo = {
|
|
@@ -2716,6 +2725,15 @@ exports.NotificationInfo = {
|
|
|
2716
2725
|
if (message.wxPusherSptList !== undefined) {
|
|
2717
2726
|
writer.uint32(562).string(message.wxPusherSptList);
|
|
2718
2727
|
}
|
|
2728
|
+
if (message.wpushApiKey !== undefined) {
|
|
2729
|
+
writer.uint32(570).string(message.wpushApiKey);
|
|
2730
|
+
}
|
|
2731
|
+
if (message.wpushChannel !== undefined) {
|
|
2732
|
+
writer.uint32(578).string(message.wpushChannel);
|
|
2733
|
+
}
|
|
2734
|
+
if (message.wpushTopicCode !== undefined) {
|
|
2735
|
+
writer.uint32(586).string(message.wpushTopicCode);
|
|
2736
|
+
}
|
|
2719
2737
|
return writer;
|
|
2720
2738
|
},
|
|
2721
2739
|
decode(input, length) {
|
|
@@ -3215,6 +3233,27 @@ exports.NotificationInfo = {
|
|
|
3215
3233
|
message.wxPusherSptList = reader.string();
|
|
3216
3234
|
continue;
|
|
3217
3235
|
}
|
|
3236
|
+
case 71: {
|
|
3237
|
+
if (tag !== 570) {
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3240
|
+
message.wpushApiKey = reader.string();
|
|
3241
|
+
continue;
|
|
3242
|
+
}
|
|
3243
|
+
case 72: {
|
|
3244
|
+
if (tag !== 578) {
|
|
3245
|
+
break;
|
|
3246
|
+
}
|
|
3247
|
+
message.wpushChannel = reader.string();
|
|
3248
|
+
continue;
|
|
3249
|
+
}
|
|
3250
|
+
case 73: {
|
|
3251
|
+
if (tag !== 586) {
|
|
3252
|
+
break;
|
|
3253
|
+
}
|
|
3254
|
+
message.wpushTopicCode = reader.string();
|
|
3255
|
+
continue;
|
|
3256
|
+
}
|
|
3218
3257
|
}
|
|
3219
3258
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3220
3259
|
break;
|
|
@@ -3307,6 +3346,9 @@ exports.NotificationInfo = {
|
|
|
3307
3346
|
: undefined,
|
|
3308
3347
|
wxPusherBotUids: isSet(object.wxPusherBotUids) ? globalThis.String(object.wxPusherBotUids) : undefined,
|
|
3309
3348
|
wxPusherSptList: isSet(object.wxPusherSptList) ? globalThis.String(object.wxPusherSptList) : undefined,
|
|
3349
|
+
wpushApiKey: isSet(object.wpushApiKey) ? globalThis.String(object.wpushApiKey) : undefined,
|
|
3350
|
+
wpushChannel: isSet(object.wpushChannel) ? globalThis.String(object.wpushChannel) : undefined,
|
|
3351
|
+
wpushTopicCode: isSet(object.wpushTopicCode) ? globalThis.String(object.wpushTopicCode) : undefined,
|
|
3310
3352
|
};
|
|
3311
3353
|
},
|
|
3312
3354
|
toJSON(message) {
|
|
@@ -3521,13 +3563,22 @@ exports.NotificationInfo = {
|
|
|
3521
3563
|
if (message.wxPusherSptList !== undefined) {
|
|
3522
3564
|
obj.wxPusherSptList = message.wxPusherSptList;
|
|
3523
3565
|
}
|
|
3566
|
+
if (message.wpushApiKey !== undefined) {
|
|
3567
|
+
obj.wpushApiKey = message.wpushApiKey;
|
|
3568
|
+
}
|
|
3569
|
+
if (message.wpushChannel !== undefined) {
|
|
3570
|
+
obj.wpushChannel = message.wpushChannel;
|
|
3571
|
+
}
|
|
3572
|
+
if (message.wpushTopicCode !== undefined) {
|
|
3573
|
+
obj.wpushTopicCode = message.wpushTopicCode;
|
|
3574
|
+
}
|
|
3524
3575
|
return obj;
|
|
3525
3576
|
},
|
|
3526
3577
|
create(base) {
|
|
3527
3578
|
return exports.NotificationInfo.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
3528
3579
|
},
|
|
3529
3580
|
fromPartial(object) {
|
|
3530
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45;
|
|
3581
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48;
|
|
3531
3582
|
const message = createBaseNotificationInfo();
|
|
3532
3583
|
message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
|
|
3533
3584
|
message.gotifyUrl = (_b = object.gotifyUrl) !== null && _b !== void 0 ? _b : undefined;
|
|
@@ -3599,6 +3650,9 @@ exports.NotificationInfo = {
|
|
|
3599
3650
|
message.wxPusherBotTopicIds = (_43 = object.wxPusherBotTopicIds) !== null && _43 !== void 0 ? _43 : undefined;
|
|
3600
3651
|
message.wxPusherBotUids = (_44 = object.wxPusherBotUids) !== null && _44 !== void 0 ? _44 : undefined;
|
|
3601
3652
|
message.wxPusherSptList = (_45 = object.wxPusherSptList) !== null && _45 !== void 0 ? _45 : undefined;
|
|
3653
|
+
message.wpushApiKey = (_46 = object.wpushApiKey) !== null && _46 !== void 0 ? _46 : undefined;
|
|
3654
|
+
message.wpushChannel = (_47 = object.wpushChannel) !== null && _47 !== void 0 ? _47 : undefined;
|
|
3655
|
+
message.wpushTopicCode = (_48 = object.wpushTopicCode) !== null && _48 !== void 0 ? _48 : undefined;
|
|
3602
3656
|
return message;
|
|
3603
3657
|
},
|
|
3604
3658
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
4
|
// protoc-gen-ts_proto v2.6.1
|
|
5
|
-
// protoc v3.
|
|
5
|
+
// protoc v3.17.3
|
|
6
6
|
// source: back/protos/cron.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.CronClient = exports.CronService = exports.DeleteCronResponse = exports.DeleteCronRequest = exports.AddCronResponse = exports.AddCronRequest = exports.ICron = exports.ISchedule = exports.protobufPackage = void 0;
|
|
@@ -180,13 +180,16 @@ exports.ICron = {
|
|
|
180
180
|
},
|
|
181
181
|
};
|
|
182
182
|
function createBaseAddCronRequest() {
|
|
183
|
-
return { crons: [] };
|
|
183
|
+
return { crons: [], replace: false };
|
|
184
184
|
}
|
|
185
185
|
exports.AddCronRequest = {
|
|
186
186
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
187
187
|
for (const v of message.crons) {
|
|
188
188
|
exports.ICron.encode(v, writer.uint32(10).fork()).join();
|
|
189
189
|
}
|
|
190
|
+
if (message.replace !== false) {
|
|
191
|
+
writer.uint32(16).bool(message.replace);
|
|
192
|
+
}
|
|
190
193
|
return writer;
|
|
191
194
|
},
|
|
192
195
|
decode(input, length) {
|
|
@@ -203,6 +206,13 @@ exports.AddCronRequest = {
|
|
|
203
206
|
message.crons.push(exports.ICron.decode(reader, reader.uint32()));
|
|
204
207
|
continue;
|
|
205
208
|
}
|
|
209
|
+
case 2: {
|
|
210
|
+
if (tag !== 16) {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
message.replace = reader.bool();
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
206
216
|
}
|
|
207
217
|
if ((tag & 7) === 4 || tag === 0) {
|
|
208
218
|
break;
|
|
@@ -212,7 +222,10 @@ exports.AddCronRequest = {
|
|
|
212
222
|
return message;
|
|
213
223
|
},
|
|
214
224
|
fromJSON(object) {
|
|
215
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
crons: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.crons) ? object.crons.map((e) => exports.ICron.fromJSON(e)) : [],
|
|
227
|
+
replace: isSet(object.replace) ? globalThis.Boolean(object.replace) : false,
|
|
228
|
+
};
|
|
216
229
|
},
|
|
217
230
|
toJSON(message) {
|
|
218
231
|
var _a;
|
|
@@ -220,15 +233,19 @@ exports.AddCronRequest = {
|
|
|
220
233
|
if ((_a = message.crons) === null || _a === void 0 ? void 0 : _a.length) {
|
|
221
234
|
obj.crons = message.crons.map((e) => exports.ICron.toJSON(e));
|
|
222
235
|
}
|
|
236
|
+
if (message.replace !== false) {
|
|
237
|
+
obj.replace = message.replace;
|
|
238
|
+
}
|
|
223
239
|
return obj;
|
|
224
240
|
},
|
|
225
241
|
create(base) {
|
|
226
242
|
return exports.AddCronRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
227
243
|
},
|
|
228
244
|
fromPartial(object) {
|
|
229
|
-
var _a;
|
|
245
|
+
var _a, _b;
|
|
230
246
|
const message = createBaseAddCronRequest();
|
|
231
247
|
message.crons = ((_a = object.crons) === null || _a === void 0 ? void 0 : _a.map((e) => exports.ICron.fromPartial(e))) || [];
|
|
248
|
+
message.replace = (_b = object.replace) !== null && _b !== void 0 ? _b : false;
|
|
232
249
|
return message;
|
|
233
250
|
},
|
|
234
251
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
4
|
// protoc-gen-ts_proto v2.6.1
|
|
5
|
-
// protoc v3.
|
|
5
|
+
// protoc v3.17.3
|
|
6
6
|
// source: back/protos/health.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.HealthClient = exports.HealthService = exports.HealthCheckResponse = exports.HealthCheckRequest = exports.healthCheckResponse_ServingStatusToJSON = exports.healthCheckResponse_ServingStatusFromJSON = exports.HealthCheckResponse_ServingStatus = exports.protobufPackage = void 0;
|
|
@@ -53,6 +53,15 @@ const addCron = (call, callback) => {
|
|
|
53
53
|
callback(err, null);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
+
// Recovery replaces the whole snapshot, including deletions and disabled jobs.
|
|
57
|
+
// Validation above must finish before touching the previous schedule.
|
|
58
|
+
if (call.request.replace) {
|
|
59
|
+
for (const jobs of data_1.scheduleStacks.values()) {
|
|
60
|
+
for (const job of jobs)
|
|
61
|
+
job === null || job === void 0 ? void 0 : job.cancel();
|
|
62
|
+
}
|
|
63
|
+
data_1.scheduleStacks.clear();
|
|
64
|
+
}
|
|
56
65
|
// ===== 第二遍:注册所有任务 =====
|
|
57
66
|
for (const item of call.request.crons) {
|
|
58
67
|
const { id, schedule, command, extra_schedules, name } = item;
|
|
@@ -22,6 +22,7 @@ const logger_1 = __importDefault(require("../loaders/logger"));
|
|
|
22
22
|
const pick_1 = __importDefault(require("lodash/pick"));
|
|
23
23
|
const system_1 = __importDefault(require("../services/system"));
|
|
24
24
|
const cron_1 = __importDefault(require("../services/cron"));
|
|
25
|
+
const sequelize_1 = require("sequelize");
|
|
25
26
|
typedi_1.Container.set('logger', logger_1.default);
|
|
26
27
|
const getEnvs = async (call, callback) => {
|
|
27
28
|
try {
|
|
@@ -200,10 +201,12 @@ const systemNotify = async (call, callback) => {
|
|
|
200
201
|
};
|
|
201
202
|
exports.systemNotify = systemNotify;
|
|
202
203
|
const normalizeCronData = (data) => {
|
|
203
|
-
var _a, _b, _c, _d, _e;
|
|
204
|
+
var _a, _b, _c, _d, _e, _f;
|
|
204
205
|
if (!data)
|
|
205
206
|
return undefined;
|
|
206
|
-
|
|
207
|
+
// create() returns a Sequelize instance; spreading it omits attribute getters.
|
|
208
|
+
const cron = data instanceof sequelize_1.Model ? data.get({ plain: true }) : data;
|
|
209
|
+
return Object.assign(Object.assign({}, cron), { labels: (_a = cron.labels) !== null && _a !== void 0 ? _a : [], sub_id: (_b = cron.sub_id) !== null && _b !== void 0 ? _b : undefined, extra_schedules: (_c = cron.extra_schedules) !== null && _c !== void 0 ? _c : [], pid: (_d = cron.pid) !== null && _d !== void 0 ? _d : undefined, task_before: (_e = cron.task_before) !== null && _e !== void 0 ? _e : undefined, task_after: (_f = cron.task_after) !== null && _f !== void 0 ? _f : undefined });
|
|
207
210
|
};
|
|
208
211
|
const getCronDetail = async (call, callback) => {
|
|
209
212
|
try {
|
|
@@ -7,10 +7,30 @@ const grpc_js_1 = require("@grpc/grpc-js");
|
|
|
7
7
|
const cron_1 = require("../protos/cron");
|
|
8
8
|
const config_1 = __importDefault(require("../config"));
|
|
9
9
|
const grpcCerts_1 = require("../config/grpcCerts");
|
|
10
|
+
const health_1 = require("../protos/health");
|
|
11
|
+
const schedulerReadiness_1 = require("../shared/schedulerReadiness");
|
|
10
12
|
class Client {
|
|
11
13
|
constructor() {
|
|
14
|
+
this.readiness = new schedulerReadiness_1.SchedulerReadiness(() => this.probe());
|
|
12
15
|
this._client = null;
|
|
13
16
|
}
|
|
17
|
+
async waitForReady(timeoutMs) {
|
|
18
|
+
try {
|
|
19
|
+
await new Promise((resolve, reject) => {
|
|
20
|
+
this.client.waitForReady(Date.now() + timeoutMs, (err) => err ? reject(err) : resolve());
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
this.readiness.invalidate();
|
|
25
|
+
throw Object.assign(error instanceof Error ? error : new Error(String(error)), { status: 503 });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async probe() {
|
|
29
|
+
await this.waitForReady(1000);
|
|
30
|
+
await new Promise((resolve, reject) => {
|
|
31
|
+
this.client.makeUnaryRequest(health_1.HealthService.check.path, health_1.HealthService.check.requestSerialize, health_1.HealthService.check.responseDeserialize, { service: 'scheduler' }, { deadline: Date.now() + 1000 }, (err, res) => err ? reject(err) : (res === null || res === void 0 ? void 0 : res.status) === 1 ? resolve() : reject(new Error('Scheduler unavailable')));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
14
34
|
get client() {
|
|
15
35
|
if (!this._client) {
|
|
16
36
|
const tlsConfig = (0, grpcCerts_1.getGrpcCerts)();
|
|
@@ -18,21 +38,33 @@ class Client {
|
|
|
18
38
|
}
|
|
19
39
|
return this._client;
|
|
20
40
|
}
|
|
21
|
-
addCron(request) {
|
|
41
|
+
async addCron(request, replace = false) {
|
|
42
|
+
await this.waitForReady(2000);
|
|
22
43
|
return new Promise((resolve, reject) => {
|
|
23
|
-
this.client.addCron({ crons: request }, (err, res) => {
|
|
44
|
+
this.client.addCron({ crons: request, replace }, new grpc_js_1.Metadata(), { deadline: Date.now() + 5000 }, (err, res) => {
|
|
24
45
|
if (err) {
|
|
25
|
-
|
|
46
|
+
if (err.code === grpc_js_1.status.UNAVAILABLE || err.code === grpc_js_1.status.DEADLINE_EXCEEDED) {
|
|
47
|
+
// A timed-out write may already have reached the scheduler.
|
|
48
|
+
// Reconcile its state from the DB instead of replaying the RPC.
|
|
49
|
+
this.readiness.invalidate();
|
|
50
|
+
Object.assign(err, { status: 503 });
|
|
51
|
+
}
|
|
52
|
+
return reject(err);
|
|
26
53
|
}
|
|
27
54
|
resolve(res);
|
|
28
55
|
});
|
|
29
56
|
});
|
|
30
57
|
}
|
|
31
|
-
delCron(request) {
|
|
58
|
+
async delCron(request) {
|
|
59
|
+
await this.waitForReady(2000);
|
|
32
60
|
return new Promise((resolve, reject) => {
|
|
33
|
-
this.client.delCron({ ids: request }, (err, res) => {
|
|
61
|
+
this.client.delCron({ ids: request }, new grpc_js_1.Metadata(), { deadline: Date.now() + 5000 }, (err, res) => {
|
|
34
62
|
if (err) {
|
|
35
|
-
|
|
63
|
+
if (err.code === grpc_js_1.status.UNAVAILABLE || err.code === grpc_js_1.status.DEADLINE_EXCEEDED) {
|
|
64
|
+
this.readiness.invalidate();
|
|
65
|
+
Object.assign(err, { status: 503 });
|
|
66
|
+
}
|
|
67
|
+
return reject(err);
|
|
36
68
|
}
|
|
37
69
|
resolve(res);
|
|
38
70
|
});
|
|
@@ -4,17 +4,82 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.check = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const undici_1 = require("undici");
|
|
7
10
|
const config_1 = __importDefault(require("../config"));
|
|
8
|
-
|
|
11
|
+
function formatError(error) {
|
|
12
|
+
if (!(error instanceof Error)) {
|
|
13
|
+
return String(error);
|
|
14
|
+
}
|
|
15
|
+
const detailedError = error;
|
|
16
|
+
const details = [error.message, detailedError.code];
|
|
17
|
+
if (Array.isArray(detailedError.errors)) {
|
|
18
|
+
details.push(...detailedError.errors.map(formatError));
|
|
19
|
+
}
|
|
20
|
+
else if (detailedError.cause) {
|
|
21
|
+
details.push(formatError(detailedError.cause));
|
|
22
|
+
}
|
|
23
|
+
return [...new Set(details.filter(Boolean))].join(': ') || error.name;
|
|
24
|
+
}
|
|
25
|
+
async function getRecentSystemLog(lineLimit = 300) {
|
|
26
|
+
try {
|
|
27
|
+
const entries = await promises_1.default.readdir(config_1.default.systemLogPath);
|
|
28
|
+
const latestLog = entries
|
|
29
|
+
.filter((entry) => entry.endsWith('.log'))
|
|
30
|
+
.sort()
|
|
31
|
+
.at(-1);
|
|
32
|
+
if (!latestLog) {
|
|
33
|
+
return `No system log found in ${config_1.default.systemLogPath}`;
|
|
34
|
+
}
|
|
35
|
+
const content = await promises_1.default.readFile(path_1.default.join(config_1.default.systemLogPath, latestLog), 'utf8');
|
|
36
|
+
return content.split('\n').slice(-lineLimit).join('\n').trim();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return `Unable to read system log from ${config_1.default.systemLogPath}: ${error instanceof Error ? error.message : String(error)}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
9
42
|
const check = async (call, callback) => {
|
|
43
|
+
var _a;
|
|
10
44
|
switch (call.request.service) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
45
|
+
// Local scheduler liveness only: never call HTTP from this probe.
|
|
46
|
+
case 'scheduler':
|
|
47
|
+
return callback(null, { status: 1 });
|
|
48
|
+
case 'cron': {
|
|
49
|
+
const healthUrl = `http://localhost:${config_1.default.port}${config_1.default.baseUrl || ''}/api/health`;
|
|
50
|
+
let failure = '';
|
|
51
|
+
try {
|
|
52
|
+
const response = await (0, undici_1.request)(healthUrl, {
|
|
53
|
+
method: 'GET',
|
|
54
|
+
headersTimeout: 5000,
|
|
55
|
+
bodyTimeout: 5000,
|
|
56
|
+
});
|
|
57
|
+
const body = (await response.body.json());
|
|
58
|
+
if (response.statusCode >= 200 &&
|
|
59
|
+
response.statusCode < 300 &&
|
|
60
|
+
body.code === 200 &&
|
|
61
|
+
((_a = body.data) === null || _a === void 0 ? void 0 : _a.status) === 'ok') {
|
|
62
|
+
return callback(null, { status: 1 });
|
|
63
|
+
}
|
|
64
|
+
failure = `HTTP ${response.statusCode}: ${JSON.stringify(body)}`;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
failure = formatError(error);
|
|
15
68
|
}
|
|
16
|
-
const
|
|
17
|
-
|
|
69
|
+
const systemLog = await getRecentSystemLog();
|
|
70
|
+
const containerHint = process.env.QL_CONTAINER === 'true'
|
|
71
|
+
? 'PM2 file logging is disabled in containers. Check `docker logs <container>` for early startup errors.'
|
|
72
|
+
: 'Check `pm2 logs qinglong --lines 300` for early startup errors.';
|
|
73
|
+
return callback(new Error([
|
|
74
|
+
`HTTP health check failed: ${healthUrl}`,
|
|
75
|
+
failure,
|
|
76
|
+
containerHint,
|
|
77
|
+
`Recent system log (${config_1.default.systemLogPath}):`,
|
|
78
|
+
systemLog,
|
|
79
|
+
]
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.join('\n')));
|
|
82
|
+
}
|
|
18
83
|
default:
|
|
19
84
|
return callback(null, { status: 1 });
|
|
20
85
|
}
|
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
10
|
};
|
|
@@ -36,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
13
|
};
|
|
37
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
15
|
const typedi_1 = require("typedi");
|
|
39
|
-
const path_1 = __importStar(require("path"));
|
|
40
16
|
const config_1 = __importDefault(require("../config"));
|
|
41
17
|
const util_1 = require("../config/util");
|
|
42
18
|
const i18n_1 = require("../shared/i18n");
|
|
43
19
|
const undici_1 = require("undici");
|
|
20
|
+
const fileAccess_1 = require("../shared/fileAccess");
|
|
44
21
|
let ConfigService = class ConfigService {
|
|
45
22
|
constructor() { }
|
|
46
23
|
async getFile(filePath, res) {
|
|
@@ -48,31 +25,17 @@ let ConfigService = class ConfigService {
|
|
|
48
25
|
if (!filePath) {
|
|
49
26
|
return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
|
|
50
27
|
}
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const resolvedRoot = path_1.default.resolve(config_1.default.rootPath, normalized);
|
|
56
|
-
const resolvedConfig = path_1.default.resolve(config_1.default.configPath, normalized);
|
|
57
|
-
const isValidPath = resolvedRoot.startsWith(config_1.default.scriptPath) ||
|
|
58
|
-
resolvedRoot.startsWith(config_1.default.configPath) ||
|
|
59
|
-
resolvedConfig.startsWith(config_1.default.scriptPath) ||
|
|
60
|
-
resolvedConfig.startsWith(config_1.default.configPath);
|
|
61
|
-
if (!isValidPath) {
|
|
62
|
-
return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
|
|
63
|
-
}
|
|
64
|
-
if (config_1.default.blackFileList.includes(path_1.default.basename(normalized))) {
|
|
28
|
+
const scriptFile = filePath.startsWith('data/scripts/');
|
|
29
|
+
const resolved = (0, fileAccess_1.resolveFileAccess)(scriptFile ? config_1.default.scriptPath : config_1.default.configPath, [scriptFile ? filePath.slice('data/scripts/'.length) : filePath], config_1.default.blackFileList);
|
|
30
|
+
if (!resolved) {
|
|
65
31
|
return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
|
|
66
32
|
}
|
|
67
33
|
if (filePath.startsWith('sample/')) {
|
|
68
34
|
const res = await (0, undici_1.request)(`https://gitlab.com/whyour/qinglong/-/raw/master/${filePath}`);
|
|
69
35
|
content = await res.body.text();
|
|
70
36
|
}
|
|
71
|
-
else if (filePath.startsWith('data/scripts/')) {
|
|
72
|
-
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, filePath));
|
|
73
|
-
}
|
|
74
37
|
else {
|
|
75
|
-
content = await (0, util_1.getFileContentByName)(
|
|
38
|
+
content = await (0, util_1.getFileContentByName)(resolved);
|
|
76
39
|
}
|
|
77
40
|
res.send({ code: 200, data: content });
|
|
78
41
|
}
|