@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
|
@@ -0,0 +1,63 @@
|
|
|
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 celebrate_1 = require("celebrate");
|
|
8
|
+
const typedi_1 = require("typedi");
|
|
9
|
+
const retention_1 = __importDefault(require("../services/retention"));
|
|
10
|
+
const retention_2 = require("../shared/retention");
|
|
11
|
+
const route = (0, express_1.Router)();
|
|
12
|
+
const policySchema = {
|
|
13
|
+
runningInstanceRetentionDays: celebrate_1.Joi.number()
|
|
14
|
+
.integer()
|
|
15
|
+
.min(0)
|
|
16
|
+
.max(retention_2.MAX_RETENTION_DAYS)
|
|
17
|
+
.required(),
|
|
18
|
+
cronStatRetentionDays: celebrate_1.Joi.number()
|
|
19
|
+
.integer()
|
|
20
|
+
.min(0)
|
|
21
|
+
.max(retention_2.MAX_RETENTION_DAYS)
|
|
22
|
+
.required(),
|
|
23
|
+
};
|
|
24
|
+
const cleanupSchema = Object.assign(Object.assign({}, policySchema), { dependenceCacheTypes: celebrate_1.Joi.array()
|
|
25
|
+
.items(celebrate_1.Joi.string().valid('node', 'python3'))
|
|
26
|
+
.unique()
|
|
27
|
+
.default([]), compactDatabase: celebrate_1.Joi.boolean().default(false) });
|
|
28
|
+
exports.default = (app) => {
|
|
29
|
+
app.use('/system/storage-retention', route);
|
|
30
|
+
route.put('/config', (0, celebrate_1.celebrate)({ body: celebrate_1.Joi.object(policySchema) }), async (req, res, next) => {
|
|
31
|
+
try {
|
|
32
|
+
const service = typedi_1.Container.get(retention_1.default);
|
|
33
|
+
const data = await service.updatePolicy(req.body);
|
|
34
|
+
res.send({ code: 200, data });
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
next(error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
route.post('/preview', (0, celebrate_1.celebrate)({ body: celebrate_1.Joi.object(cleanupSchema) }), async (req, res, next) => {
|
|
41
|
+
try {
|
|
42
|
+
const service = typedi_1.Container.get(retention_1.default);
|
|
43
|
+
const data = await service.preview(req.body);
|
|
44
|
+
res.send({ code: 200, data });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
next(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
route.post('/cleanup', (0, celebrate_1.celebrate)({
|
|
51
|
+
body: celebrate_1.Joi.object(Object.assign(Object.assign({}, cleanupSchema), { confirmation: celebrate_1.Joi.string().valid('CLEAN').required() })),
|
|
52
|
+
}), async (req, res, next) => {
|
|
53
|
+
try {
|
|
54
|
+
const service = typedi_1.Container.get(retention_1.default);
|
|
55
|
+
const data = await service.cleanup(req.body);
|
|
56
|
+
res.send({ code: 200, data });
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
next(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=retention.js.map
|
|
@@ -26,6 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const crypto_1 = require("crypto");
|
|
30
|
+
const fileAccess_1 = require("../shared/fileAccess");
|
|
29
31
|
const util_1 = require("../config/util");
|
|
30
32
|
const express_1 = require("express");
|
|
31
33
|
const typedi_1 = require("typedi");
|
|
@@ -40,14 +42,14 @@ const utils_1 = require("../shared/utils");
|
|
|
40
42
|
const route = (0, express_1.Router)();
|
|
41
43
|
function isPathAllowed(targetPath) {
|
|
42
44
|
const resolved = path_1.default.resolve(targetPath);
|
|
43
|
-
return config_1.default.writePathList.some((x) =>
|
|
45
|
+
return config_1.default.writePathList.some((x) => Boolean((0, fileAccess_1.resolveFileAccess)(x, [resolved], config_1.default.blackFileList)));
|
|
44
46
|
}
|
|
45
47
|
const storage = multer_1.default.diskStorage({
|
|
46
48
|
destination: function (req, file, cb) {
|
|
47
|
-
cb(null, config_1.default.
|
|
49
|
+
cb(null, config_1.default.tmpPath);
|
|
48
50
|
},
|
|
49
51
|
filename: function (req, file, cb) {
|
|
50
|
-
cb(null,
|
|
52
|
+
cb(null, (0, crypto_1.randomUUID)());
|
|
51
53
|
},
|
|
52
54
|
});
|
|
53
55
|
const upload = (0, multer_1.default)({ storage: storage });
|
|
@@ -70,6 +72,9 @@ exports.default = (app) => {
|
|
|
70
72
|
'package-lock.json',
|
|
71
73
|
];
|
|
72
74
|
if (req.query.path) {
|
|
75
|
+
if (!(0, fileAccess_1.resolveFileAccess)(config_1.default.scriptPath, [req.query.path], config_1.default.blackFileList)) {
|
|
76
|
+
return res.send({ code: 403, message: (0, i18n_1.t)('暂无权限') });
|
|
77
|
+
}
|
|
73
78
|
result = await (0, util_1.readDir)(req.query.path, config_1.default.scriptPath, blacklist);
|
|
74
79
|
}
|
|
75
80
|
else {
|
|
@@ -108,25 +113,20 @@ exports.default = (app) => {
|
|
|
108
113
|
return next(e);
|
|
109
114
|
}
|
|
110
115
|
});
|
|
111
|
-
route.get('/:file', (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
path: celebrate_1.Joi.string().optional().allow(''),
|
|
117
|
-
}).unknown(true),
|
|
118
|
-
}), async (req, res, next) => {
|
|
119
|
-
var _a;
|
|
120
|
-
try {
|
|
121
|
-
const scriptService = typedi_1.Container.get(script_1.default);
|
|
122
|
-
const content = await scriptService.getFile(((_a = req.query) === null || _a === void 0 ? void 0 : _a.path) || '', req.params.file);
|
|
123
|
-
res.send({ code: 200, data: content });
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
return next(e);
|
|
127
|
-
}
|
|
116
|
+
route.get('/:file', (req, res) => {
|
|
117
|
+
return res.send({
|
|
118
|
+
code: 410,
|
|
119
|
+
message: (0, i18n_1.t)('接口已下线,请使用 /scripts/detail 接口'),
|
|
120
|
+
});
|
|
128
121
|
});
|
|
129
|
-
route.post('/',
|
|
122
|
+
route.post('/', (req, res, next) => {
|
|
123
|
+
res.on('finish', () => {
|
|
124
|
+
var _a;
|
|
125
|
+
if ((_a = req.file) === null || _a === void 0 ? void 0 : _a.path)
|
|
126
|
+
fs.unlink(req.file.path).catch(() => undefined);
|
|
127
|
+
});
|
|
128
|
+
next();
|
|
129
|
+
}, upload.single('file'), (0, celebrate_1.celebrate)({
|
|
130
130
|
body: celebrate_1.Joi.object({
|
|
131
131
|
filename: celebrate_1.Joi.string().required(),
|
|
132
132
|
path: celebrate_1.Joi.string().optional().allow(''),
|
|
@@ -158,7 +158,8 @@ exports.default = (app) => {
|
|
|
158
158
|
if (!isPathAllowed(uploadPath)) {
|
|
159
159
|
return res.send({ code: 403, message: (0, i18n_1.t)('暂无权限') });
|
|
160
160
|
}
|
|
161
|
-
await fs.
|
|
161
|
+
await fs.copyFile(req.file.path, uploadPath);
|
|
162
|
+
await fs.unlink(req.file.path);
|
|
162
163
|
return res.send({ code: 200 });
|
|
163
164
|
}
|
|
164
165
|
if (directory) {
|
|
@@ -124,12 +124,26 @@ exports.default = (app) => {
|
|
|
124
124
|
params: celebrate_1.Joi.object({
|
|
125
125
|
id: celebrate_1.Joi.number().required(),
|
|
126
126
|
}),
|
|
127
|
+
query: celebrate_1.Joi.object({
|
|
128
|
+
offset: celebrate_1.Joi.number().integer().min(0).optional(),
|
|
129
|
+
limit: celebrate_1.Joi.number()
|
|
130
|
+
.integer()
|
|
131
|
+
.min(1)
|
|
132
|
+
.max(1024 * 1024)
|
|
133
|
+
.optional(),
|
|
134
|
+
tail: celebrate_1.Joi.boolean().optional(),
|
|
135
|
+
t: celebrate_1.Joi.string().optional(),
|
|
136
|
+
}).unknown(true),
|
|
127
137
|
}), async (req, res, next) => {
|
|
128
138
|
const logger = typedi_1.Container.get('logger');
|
|
129
139
|
try {
|
|
130
140
|
const subscriptionService = typedi_1.Container.get(subscription_1.default);
|
|
131
|
-
const
|
|
132
|
-
|
|
141
|
+
const result = await subscriptionService.log(req.params.id, {
|
|
142
|
+
offset: req.query.offset,
|
|
143
|
+
limit: req.query.limit,
|
|
144
|
+
tail: req.query.tail,
|
|
145
|
+
});
|
|
146
|
+
return res.send(Object.assign({ code: 200, data: result.content }, result));
|
|
133
147
|
}
|
|
134
148
|
catch (e) {
|
|
135
149
|
return next(e);
|
|
@@ -220,8 +220,12 @@ exports.default = (app) => {
|
|
|
220
220
|
},
|
|
221
221
|
onEnd: async (cp, endTime, diff) => {
|
|
222
222
|
// Close the stream after task completion
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
try {
|
|
224
|
+
await logStreamManager_1.logStreamManager.closeStream(await (0, util_1.handleLogPath)(logPath));
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
res.end();
|
|
228
|
+
}
|
|
225
229
|
},
|
|
226
230
|
onError: async (message) => {
|
|
227
231
|
res.write(message);
|
|
@@ -281,6 +285,11 @@ exports.default = (app) => {
|
|
|
281
285
|
query: {
|
|
282
286
|
startTime: celebrate_1.Joi.string().allow('').optional(),
|
|
283
287
|
endTime: celebrate_1.Joi.string().allow('').optional(),
|
|
288
|
+
limit: celebrate_1.Joi.number()
|
|
289
|
+
.integer()
|
|
290
|
+
.min(1)
|
|
291
|
+
.max(1024 * 1024)
|
|
292
|
+
.optional(),
|
|
284
293
|
t: celebrate_1.Joi.string().optional(),
|
|
285
294
|
},
|
|
286
295
|
}), async (req, res, next) => {
|
|
@@ -350,6 +359,20 @@ exports.default = (app) => {
|
|
|
350
359
|
return next(e);
|
|
351
360
|
}
|
|
352
361
|
});
|
|
362
|
+
route.put('/config/panel-title', (0, celebrate_1.celebrate)({
|
|
363
|
+
body: celebrate_1.Joi.object({
|
|
364
|
+
panelTitle: celebrate_1.Joi.string().max(100).allow('').allow(null),
|
|
365
|
+
}),
|
|
366
|
+
}), async (req, res, next) => {
|
|
367
|
+
try {
|
|
368
|
+
const systemService = typedi_1.Container.get(system_1.default);
|
|
369
|
+
const result = await systemService.updatePanelTitle(req.body);
|
|
370
|
+
res.send(result);
|
|
371
|
+
}
|
|
372
|
+
catch (e) {
|
|
373
|
+
return next(e);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
353
376
|
route.put('/config/global-ssh-key', (0, celebrate_1.celebrate)({
|
|
354
377
|
body: celebrate_1.Joi.object({
|
|
355
378
|
globalSshKey: celebrate_1.Joi.string().allow('').allow(null),
|
package/static/build/api/user.js
CHANGED
|
@@ -25,7 +25,25 @@ const storage = multer_1.default.diskStorage({
|
|
|
25
25
|
cb(null, key + ext);
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
|
-
const upload = (0, multer_1.default)({
|
|
28
|
+
const upload = (0, multer_1.default)({
|
|
29
|
+
storage,
|
|
30
|
+
limits: { fileSize: 5 * 1024 * 1024, files: 1 },
|
|
31
|
+
fileFilter: (_req, file, cb) => {
|
|
32
|
+
const ext = path_1.default.extname(file.originalname).toLowerCase();
|
|
33
|
+
const imageTypes = {
|
|
34
|
+
'.png': 'image/png',
|
|
35
|
+
'.jpg': 'image/jpeg',
|
|
36
|
+
'.jpeg': 'image/jpeg',
|
|
37
|
+
'.gif': 'image/gif',
|
|
38
|
+
'.webp': 'image/webp',
|
|
39
|
+
'.avif': 'image/avif',
|
|
40
|
+
};
|
|
41
|
+
if (imageTypes[ext] !== file.mimetype) {
|
|
42
|
+
return cb(new Error((0, i18n_1.t)('仅支持 PNG、JPEG、GIF、WebP、AVIF 图片')));
|
|
43
|
+
}
|
|
44
|
+
cb(null, true);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
29
47
|
exports.default = (app) => {
|
|
30
48
|
app.use('/user', route);
|
|
31
49
|
route.post('/login', (0, express_rate_limit_1.default)({
|
|
@@ -33,8 +51,8 @@ exports.default = (app) => {
|
|
|
33
51
|
max: 100,
|
|
34
52
|
}), (0, celebrate_1.celebrate)({
|
|
35
53
|
body: celebrate_1.Joi.object({
|
|
36
|
-
username: celebrate_1.Joi.string().required(),
|
|
37
|
-
password: celebrate_1.Joi.string().required(),
|
|
54
|
+
username: celebrate_1.Joi.string().max(1024).required(),
|
|
55
|
+
password: celebrate_1.Joi.string().max(1024).required(),
|
|
38
56
|
}),
|
|
39
57
|
}), async (req, res, next) => {
|
|
40
58
|
const logger = typedi_1.Container.get('logger');
|
|
@@ -61,8 +79,8 @@ exports.default = (app) => {
|
|
|
61
79
|
});
|
|
62
80
|
route.put('/', (0, celebrate_1.celebrate)({
|
|
63
81
|
body: celebrate_1.Joi.object({
|
|
64
|
-
username: celebrate_1.Joi.string().required(),
|
|
65
|
-
password: celebrate_1.Joi.string().required(),
|
|
82
|
+
username: celebrate_1.Joi.string().max(1024).required(),
|
|
83
|
+
password: celebrate_1.Joi.string().max(1024).required(),
|
|
66
84
|
}),
|
|
67
85
|
}), async (req, res, next) => {
|
|
68
86
|
try {
|
|
@@ -70,8 +88,8 @@ exports.default = (app) => {
|
|
|
70
88
|
return res.send({ code: 450, message: (0, i18n_1.t)('未知错误') });
|
|
71
89
|
}
|
|
72
90
|
const userService = typedi_1.Container.get(user_1.default);
|
|
73
|
-
await userService.updateUsernameAndPassword(req.body);
|
|
74
|
-
res.send(
|
|
91
|
+
const result = await userService.updateUsernameAndPassword(req.body);
|
|
92
|
+
res.send(result);
|
|
75
93
|
}
|
|
76
94
|
catch (e) {
|
|
77
95
|
return next(e);
|
|
@@ -133,11 +151,11 @@ exports.default = (app) => {
|
|
|
133
151
|
return next(e);
|
|
134
152
|
}
|
|
135
153
|
});
|
|
136
|
-
route.put('/two-factor/login', (0, celebrate_1.celebrate)({
|
|
154
|
+
route.put('/two-factor/login', (0, express_rate_limit_1.default)({ windowMs: 15 * 60 * 1000, max: 20 }), (0, celebrate_1.celebrate)({
|
|
137
155
|
body: celebrate_1.Joi.object({
|
|
138
156
|
code: celebrate_1.Joi.string().required(),
|
|
139
|
-
username: celebrate_1.Joi.string().required(),
|
|
140
|
-
password: celebrate_1.Joi.string().required(),
|
|
157
|
+
username: celebrate_1.Joi.string().max(1024).required(),
|
|
158
|
+
password: celebrate_1.Joi.string().max(1024).required(),
|
|
141
159
|
}),
|
|
142
160
|
}), async (req, res, next) => {
|
|
143
161
|
const logger = typedi_1.Container.get('logger');
|
|
@@ -161,6 +179,48 @@ exports.default = (app) => {
|
|
|
161
179
|
return next(e);
|
|
162
180
|
}
|
|
163
181
|
});
|
|
182
|
+
route.get('/ip-blacklist', async (req, res, next) => {
|
|
183
|
+
try {
|
|
184
|
+
const userService = typedi_1.Container.get(user_1.default);
|
|
185
|
+
const data = await userService.getIpBlacklist();
|
|
186
|
+
res.send({ code: 200, data });
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
return next(e);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
route.put('/ip-blacklist', (0, celebrate_1.celebrate)({
|
|
193
|
+
body: celebrate_1.Joi.object({
|
|
194
|
+
ip: celebrate_1.Joi.string()
|
|
195
|
+
.ip({ version: ['ipv4', 'ipv6'], cidr: 'forbidden' })
|
|
196
|
+
.required(),
|
|
197
|
+
}),
|
|
198
|
+
}), async (req, res, next) => {
|
|
199
|
+
try {
|
|
200
|
+
const userService = typedi_1.Container.get(user_1.default);
|
|
201
|
+
const data = await userService.blockIp(req.body.ip);
|
|
202
|
+
res.send({ code: 200, data, message: (0, i18n_1.t)('已加入 IP 黑名单') });
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
return next(e);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
route.delete('/ip-blacklist', (0, celebrate_1.celebrate)({
|
|
209
|
+
body: celebrate_1.Joi.object({
|
|
210
|
+
ip: celebrate_1.Joi.string()
|
|
211
|
+
.ip({ version: ['ipv4', 'ipv6'], cidr: 'forbidden' })
|
|
212
|
+
.required(),
|
|
213
|
+
}),
|
|
214
|
+
}), async (req, res, next) => {
|
|
215
|
+
try {
|
|
216
|
+
const userService = typedi_1.Container.get(user_1.default);
|
|
217
|
+
const data = await userService.unblockIp(req.body.ip);
|
|
218
|
+
res.send({ code: 200, data, message: (0, i18n_1.t)('已移出 IP 黑名单') });
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
return next(e);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
164
224
|
route.get('/notification', async (req, res, next) => {
|
|
165
225
|
const logger = typedi_1.Container.get('logger');
|
|
166
226
|
try {
|
|
@@ -183,17 +243,17 @@ exports.default = (app) => {
|
|
|
183
243
|
return next(e);
|
|
184
244
|
}
|
|
185
245
|
});
|
|
186
|
-
route.put('/init', (0, celebrate_1.celebrate)({
|
|
246
|
+
route.put('/init', (0, express_rate_limit_1.default)({ windowMs: 15 * 60 * 1000, max: 20 }), (0, celebrate_1.celebrate)({
|
|
187
247
|
body: celebrate_1.Joi.object({
|
|
188
|
-
username: celebrate_1.Joi.string().required(),
|
|
189
|
-
password: celebrate_1.Joi.string().required(),
|
|
248
|
+
username: celebrate_1.Joi.string().max(1024).required(),
|
|
249
|
+
password: celebrate_1.Joi.string().max(1024).required(),
|
|
190
250
|
}),
|
|
191
251
|
}), async (req, res, next) => {
|
|
192
252
|
const logger = typedi_1.Container.get('logger');
|
|
193
253
|
try {
|
|
194
254
|
const userService = typedi_1.Container.get(user_1.default);
|
|
195
|
-
await userService.
|
|
196
|
-
res.send(
|
|
255
|
+
const result = await userService.initializeUser(req.body);
|
|
256
|
+
res.send(result);
|
|
197
257
|
}
|
|
198
258
|
catch (e) {
|
|
199
259
|
return next(e);
|
package/static/build/app.js
CHANGED
|
@@ -28,26 +28,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
require("reflect-metadata");
|
|
30
30
|
const cluster_1 = __importDefault(require("cluster"));
|
|
31
|
-
const compression_1 = __importDefault(require("compression"));
|
|
32
|
-
const cors_1 = __importDefault(require("cors"));
|
|
33
|
-
const express_1 = __importDefault(require("express"));
|
|
34
|
-
const helmet_1 = __importDefault(require("helmet"));
|
|
35
31
|
const typedi_1 = require("typedi");
|
|
36
32
|
const config_1 = __importDefault(require("./config"));
|
|
37
33
|
const logger_1 = __importDefault(require("./loaders/logger"));
|
|
38
|
-
const
|
|
34
|
+
const errors_1 = require("./shared/errors");
|
|
39
35
|
class Application {
|
|
40
36
|
constructor() {
|
|
41
37
|
this.isShuttingDown = false;
|
|
42
38
|
this.workerMetadataMap = new Map();
|
|
43
|
-
this.app = (0, express_1.default)();
|
|
44
|
-
// 创建一个全局中间件,删除查询参数中的t
|
|
45
|
-
this.app.use((req, res, next) => {
|
|
46
|
-
if (req.query.t) {
|
|
47
|
-
delete req.query.t;
|
|
48
|
-
}
|
|
49
|
-
next();
|
|
50
|
-
});
|
|
51
39
|
}
|
|
52
40
|
async start() {
|
|
53
41
|
try {
|
|
@@ -62,7 +50,7 @@ class Application {
|
|
|
62
50
|
}
|
|
63
51
|
}
|
|
64
52
|
catch (error) {
|
|
65
|
-
logger_1.default.error(
|
|
53
|
+
logger_1.default.error(`Failed to start application:\n${(0, errors_1.errStack)(error)}`);
|
|
66
54
|
process.exit(1);
|
|
67
55
|
}
|
|
68
56
|
}
|
|
@@ -76,16 +64,23 @@ class Application {
|
|
|
76
64
|
this.httpWorker = this.forkWorker('http');
|
|
77
65
|
})
|
|
78
66
|
.catch((error) => {
|
|
79
|
-
logger_1.default.error(
|
|
67
|
+
logger_1.default.error(`[boot] Failed to wait for gRPC worker:\n${(0, errors_1.errStack)(error)}`);
|
|
80
68
|
process.exit(1);
|
|
81
69
|
});
|
|
82
70
|
cluster_1.default.on('exit', (worker, code, signal) => {
|
|
71
|
+
var _a;
|
|
83
72
|
const metadata = this.workerMetadataMap.get(worker.id);
|
|
84
73
|
if (metadata) {
|
|
85
74
|
if (!this.isShuttingDown) {
|
|
86
75
|
logger_1.default.error(`${metadata.serviceType} worker ${worker.process.pid} died (${signal || code}). Restarting...`);
|
|
87
76
|
// If gRPC worker died, restart it and wait for it to be ready
|
|
88
77
|
if (metadata.serviceType === 'grpc') {
|
|
78
|
+
try {
|
|
79
|
+
(_a = this.httpWorker) === null || _a === void 0 ? void 0 : _a.send('scheduler-unavailable');
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger_1.default.warn('Unable to notify HTTP worker of scheduler exit');
|
|
83
|
+
}
|
|
89
84
|
const newGrpcWorker = this.forkWorker('grpc');
|
|
90
85
|
this.waitForWorkerReady(newGrpcWorker, 30000)
|
|
91
86
|
.then(() => {
|
|
@@ -97,12 +92,12 @@ class Application {
|
|
|
97
92
|
logger_1.default.info('Sent reregister-crons message to HTTP worker');
|
|
98
93
|
}
|
|
99
94
|
catch (error) {
|
|
100
|
-
logger_1.default.error(
|
|
95
|
+
logger_1.default.error(`Failed to send reregister-crons message:\n${(0, errors_1.errStack)(error)}`);
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
})
|
|
104
99
|
.catch((error) => {
|
|
105
|
-
logger_1.default.error(
|
|
100
|
+
logger_1.default.error(`Failed to restart gRPC worker:\n${(0, errors_1.errStack)(error)}`);
|
|
106
101
|
process.exit(1);
|
|
107
102
|
});
|
|
108
103
|
}
|
|
@@ -136,7 +131,14 @@ class Application {
|
|
|
136
131
|
});
|
|
137
132
|
}
|
|
138
133
|
forkWorker(serviceType) {
|
|
139
|
-
const
|
|
134
|
+
const workerEnv = { SERVICE_TYPE: serviceType };
|
|
135
|
+
// PM2's fork launcher is inherited by our own cluster workers. Their APM
|
|
136
|
+
// messages go to this primary, not PM2, and duplicate its sampling work.
|
|
137
|
+
// Keep primary monitoring and allow restoring the inherited worker APM.
|
|
138
|
+
if (process.env.pm_id !== undefined && process.env.QL_WORKER_APM !== 'true') {
|
|
139
|
+
workerEnv.pmx = 'false';
|
|
140
|
+
}
|
|
141
|
+
const worker = cluster_1.default.fork(workerEnv);
|
|
140
142
|
this.workerMetadataMap.set(worker.id, {
|
|
141
143
|
id: worker.id,
|
|
142
144
|
pid: worker.process.pid,
|
|
@@ -146,16 +148,31 @@ class Application {
|
|
|
146
148
|
return worker;
|
|
147
149
|
}
|
|
148
150
|
async initializeDatabase() {
|
|
149
|
-
const
|
|
150
|
-
await
|
|
151
|
+
const { runStartupProcess } = await Promise.resolve().then(() => __importStar(require('./shared/startupProcess')));
|
|
152
|
+
await runStartupProcess(require.resolve('./bootstrap/database'));
|
|
151
153
|
}
|
|
152
|
-
setupMiddlewares() {
|
|
153
|
-
|
|
154
|
+
async setupMiddlewares() {
|
|
155
|
+
// Only the HTTP worker needs an Express application and its middleware.
|
|
156
|
+
const [{ default: createExpress }, { default: helmet }, { default: cors }, { default: compression }, { monitoringMiddleware },] = await Promise.all([
|
|
157
|
+
Promise.resolve().then(() => __importStar(require('express'))),
|
|
158
|
+
Promise.resolve().then(() => __importStar(require('helmet'))),
|
|
159
|
+
Promise.resolve().then(() => __importStar(require('cors'))),
|
|
160
|
+
Promise.resolve().then(() => __importStar(require('compression'))),
|
|
161
|
+
Promise.resolve().then(() => __importStar(require('./middlewares/monitoring'))),
|
|
162
|
+
]);
|
|
163
|
+
const app = createExpress();
|
|
164
|
+
app.use((req, res, next) => {
|
|
165
|
+
if (req.query.t)
|
|
166
|
+
delete req.query.t;
|
|
167
|
+
next();
|
|
168
|
+
});
|
|
169
|
+
app.use(helmet({
|
|
154
170
|
contentSecurityPolicy: false,
|
|
155
171
|
}));
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
app.use(cors(config_1.default.cors));
|
|
173
|
+
app.use(compression());
|
|
174
|
+
app.use(monitoringMiddleware);
|
|
175
|
+
return app;
|
|
159
176
|
}
|
|
160
177
|
setupMasterShutdown() {
|
|
161
178
|
const shutdown = async () => {
|
|
@@ -175,7 +192,7 @@ class Application {
|
|
|
175
192
|
worker.send('shutdown');
|
|
176
193
|
}
|
|
177
194
|
catch (error) {
|
|
178
|
-
logger_1.default.warn(`Failed to send shutdown to worker ${worker.process.pid}
|
|
195
|
+
logger_1.default.warn(`Failed to send shutdown to worker ${worker.process.pid}:\n${(0, errors_1.errStack)(error)}`);
|
|
179
196
|
}
|
|
180
197
|
});
|
|
181
198
|
workerPromises.push(exitPromise);
|
|
@@ -194,7 +211,7 @@ class Application {
|
|
|
194
211
|
process.exit(0);
|
|
195
212
|
}
|
|
196
213
|
catch (error) {
|
|
197
|
-
logger_1.default.error(
|
|
214
|
+
logger_1.default.error(`Error during worker shutdown:\n${(0, errors_1.errStack)(error)}`);
|
|
198
215
|
process.exit(1);
|
|
199
216
|
}
|
|
200
217
|
};
|
|
@@ -219,7 +236,7 @@ class Application {
|
|
|
219
236
|
(_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
|
|
220
237
|
}
|
|
221
238
|
catch (error) {
|
|
222
|
-
logger_1.default.error(`[boot] ${serviceType} worker failed
|
|
239
|
+
logger_1.default.error(`[boot] ${serviceType} worker failed:\n${(0, errors_1.errStack)(error)}`);
|
|
223
240
|
process.exit(1);
|
|
224
241
|
}
|
|
225
242
|
}
|
|
@@ -227,12 +244,12 @@ class Application {
|
|
|
227
244
|
// 在导入任何 gRPC 客户端模块之前初始化 mTLS 证书
|
|
228
245
|
const { initGrpcCerts } = await Promise.resolve().then(() => __importStar(require('./config/grpcCerts')));
|
|
229
246
|
await initGrpcCerts();
|
|
230
|
-
this.setupMiddlewares();
|
|
247
|
+
const app = await this.setupMiddlewares();
|
|
231
248
|
const { HttpServerService } = await Promise.resolve().then(() => __importStar(require('./services/http')));
|
|
232
249
|
this.httpServerService = typedi_1.Container.get(HttpServerService);
|
|
233
250
|
const appLoader = await Promise.resolve().then(() => __importStar(require('./loaders/app')));
|
|
234
|
-
await appLoader.default({ app
|
|
235
|
-
const server = await this.httpServerService.initialize(
|
|
251
|
+
await appLoader.default({ app });
|
|
252
|
+
const server = await this.httpServerService.initialize(app, config_1.default.port);
|
|
236
253
|
const serverLoader = await Promise.resolve().then(() => __importStar(require('./loaders/server')));
|
|
237
254
|
await serverLoader.default({ server });
|
|
238
255
|
this.setupWorkerShutdown('http');
|
|
@@ -248,18 +265,10 @@ class Application {
|
|
|
248
265
|
if (msg === 'shutdown') {
|
|
249
266
|
this.gracefulShutdown(serviceType);
|
|
250
267
|
}
|
|
251
|
-
else if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const CronService = (await Promise.resolve().then(() => __importStar(require('./services/cron')))).default;
|
|
256
|
-
const cronService = typedi_1.Container.get(CronService);
|
|
257
|
-
await cronService.autosave_crontab();
|
|
258
|
-
logger_1.default.info('[boot] Cron jobs re-registered successfully');
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
logger_1.default.error('[boot] Failed to re-register cron jobs:', error);
|
|
262
|
-
}
|
|
268
|
+
else if (serviceType === 'http' &&
|
|
269
|
+
(msg === 'reregister-crons' || msg === 'scheduler-unavailable')) {
|
|
270
|
+
const { default: cronClient } = await Promise.resolve().then(() => __importStar(require('./schedule/client')));
|
|
271
|
+
cronClient.readiness.invalidate();
|
|
263
272
|
}
|
|
264
273
|
});
|
|
265
274
|
const shutdown = () => this.gracefulShutdown(serviceType);
|
|
@@ -281,14 +290,14 @@ class Application {
|
|
|
281
290
|
process.exit(0);
|
|
282
291
|
}
|
|
283
292
|
catch (error) {
|
|
284
|
-
logger_1.default.error(`[${serviceType}] Error during shutdown
|
|
293
|
+
logger_1.default.error(`[${serviceType}] Error during shutdown:\n${(0, errors_1.errStack)(error)}`);
|
|
285
294
|
process.exit(1);
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
297
|
}
|
|
289
298
|
const app = new Application();
|
|
290
299
|
app.start().catch((error) => {
|
|
291
|
-
logger_1.default.error(
|
|
300
|
+
logger_1.default.error(`🙅♀️ Application failed to start:\n${(0, errors_1.errStack)(error)}`);
|
|
292
301
|
process.exit(1);
|
|
293
302
|
});
|
|
294
303
|
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const errors_1 = require("../shared/errors");
|
|
27
|
+
// Also terminate if the primary disappears without forwarding a signal.
|
|
28
|
+
const onParentDisconnect = () => process.exit(1);
|
|
29
|
+
process.once('disconnect', onParentDisconnect);
|
|
30
|
+
async function initializeDatabase() {
|
|
31
|
+
const { sequelize } = await Promise.resolve().then(() => __importStar(require('../data')));
|
|
32
|
+
try {
|
|
33
|
+
const { default: loadDatabase } = await Promise.resolve().then(() => __importStar(require('../loaders/db')));
|
|
34
|
+
await loadDatabase();
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await sequelize.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
initializeDatabase()
|
|
41
|
+
.catch((error) => {
|
|
42
|
+
console.error(`[boot] Database initialization failed:\n${(0, errors_1.errStack)(error)}`);
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
})
|
|
45
|
+
.finally(() => {
|
|
46
|
+
process.removeListener('disconnect', onParentDisconnect);
|
|
47
|
+
// Let pending log writes drain and exit naturally after closing SQLite.
|
|
48
|
+
if (process.connected)
|
|
49
|
+
process.disconnect();
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=database.js.map
|