@whyour/qinglong 2.21.0 → 2.23.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 +9 -1
- package/back/protos/cron.proto +8 -1
- package/deploy/kubernetes/README.md +81 -0
- package/deploy/kubernetes/base/kustomization.yaml +5 -0
- package/deploy/kubernetes/base/qinglong.yaml +95 -0
- package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
- 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/development/node-cron-migration.md +49 -0
- package/docs/development/task-startup.md +78 -0
- package/docs/releases/2.22.0-validation.md +49 -0
- package/docs/releases/2.22.0.md +62 -0
- package/docs/releases/2.23.0.md +33 -0
- package/docs/script-history.md +53 -0
- package/ecosystem.config.js +10 -1
- package/package.json +19 -13
- package/sample/config.sample.sh +17 -2
- package/sample/notify.js +118 -0
- package/sample/notify.py +93 -0
- package/scripts/benchmark-execution.cjs +96 -0
- package/scripts/benchmark-script-history.cjs +39 -0
- package/scripts/publish-static.sh +34 -0
- package/scripts/sync-static.sh +20 -0
- package/scripts/wait-for-mirror.sh +214 -0
- package/scripts/write-build-info.cjs +27 -0
- package/shell/api.sh +96 -83
- 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 +136 -0
- package/shell/otask.sh +17 -10
- package/shell/preload/sitecustomize.js +11 -3
- package/shell/preload/sitecustomize.py +4 -2
- package/shell/share.sh +27 -10
- package/shell/start.sh +6 -3
- package/shell/task-timeout.sh +63 -0
- package/shell/task.sh +21 -9
- package/shell/update.sh +104 -98
- package/shell/upgrade.cjs +8 -0
- package/static/build/api/clientIp.js +42 -0
- package/static/build/api/config.js +9 -21
- package/static/build/api/cron.js +39 -3
- package/static/build/api/dashboard.js +50 -6
- package/static/build/api/env.js +17 -16
- package/static/build/api/health.js +2 -2
- package/static/build/api/index.js +4 -0
- package/static/build/api/log.js +39 -19
- package/static/build/api/open.js +2 -1
- package/static/build/api/retention.js +63 -0
- package/static/build/api/script.js +172 -25
- package/static/build/api/subscription.js +19 -8
- package/static/build/api/system.js +66 -12
- package/static/build/api/user.js +75 -15
- package/static/build/app.js +63 -54
- package/static/build/bootstrap/database.js +51 -0
- package/static/build/config/const.js +2 -0
- package/static/build/config/grpcCerts.js +93 -44
- package/static/build/config/index.js +0 -4
- package/static/build/config/share.js +5 -4
- package/static/build/config/subscription.js +19 -11
- package/static/build/config/util.js +142 -45
- package/static/build/data/cron.js +1 -0
- package/static/build/data/notify.js +18 -1
- package/static/build/data/sock.js +1 -0
- package/static/build/loaders/app.js +8 -6
- package/static/build/loaders/db.js +5 -35
- package/static/build/loaders/deps.js +30 -22
- package/static/build/loaders/express.js +46 -32
- package/static/build/loaders/initData.js +26 -33
- package/static/build/loaders/initFile.js +1 -1
- package/static/build/loaders/initTask.js +14 -3
- package/static/build/loaders/server.js +1 -1
- 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/middlewares/uniqueConstraintError.js +15 -0
- package/static/build/protos/api.js +78 -2
- package/static/build/protos/cron.js +83 -5
- package/static/build/protos/health.js +1 -1
- package/static/build/schedule/addCron.js +67 -19
- package/static/build/schedule/api.js +5 -2
- package/static/build/schedule/client.js +56 -6
- package/static/build/schedule/delCron.js +11 -1
- package/static/build/schedule/health.js +72 -7
- package/static/build/schedule/setConcurrency.js +27 -0
- package/static/build/services/config.js +5 -43
- package/static/build/services/cron.js +389 -174
- package/static/build/services/dependence.js +66 -18
- package/static/build/services/env.js +1 -1
- package/static/build/services/grpc.js +4 -3
- package/static/build/services/health.js +4 -7
- package/static/build/services/http.js +9 -3
- package/static/build/services/log.js +2 -3
- package/static/build/services/metrics.js +46 -14
- package/static/build/services/notify.js +73 -5
- package/static/build/services/open.js +106 -31
- package/static/build/services/retention.js +123 -0
- package/static/build/services/schedule.js +77 -43
- package/static/build/services/script.js +4 -5
- package/static/build/services/scriptHistory.js +30 -0
- package/static/build/services/sshKey.js +39 -14
- package/static/build/services/subscription.js +161 -87
- package/static/build/services/system.js +116 -43
- package/static/build/services/user.js +255 -37
- package/static/build/shared/auth.js +22 -3
- 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/cronCommand.js +17 -0
- package/static/build/shared/cronSchedule.js +101 -0
- package/static/build/shared/cronScheduler.js +73 -0
- package/static/build/shared/errors.js +9 -0
- package/static/build/shared/fileAccess.js +60 -0
- package/static/build/shared/i18n.js +63 -4
- package/static/build/shared/logPath.js +15 -0
- package/static/build/shared/logReader.js +85 -0
- package/static/build/shared/logStreamManager.js +80 -60
- package/static/build/shared/loginThrottle.js +45 -0
- package/static/build/shared/pLimit.js +22 -8
- package/static/build/shared/password.js +30 -0
- package/static/build/shared/retention.js +58 -0
- package/static/build/shared/runCron.js +39 -17
- 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/scriptHistory.js +445 -0
- package/static/build/shared/shellQuote.js +11 -0
- package/static/build/shared/startupProcess.js +48 -0
- package/static/build/shared/store.js +7 -0
- package/static/build/shared/subscriptionMutationLock.js +34 -0
- package/static/build/shared/subscriptionPath.js +41 -0
- package/static/build/shared/subscriptionStorage.js +98 -0
- package/static/build/shared/trustProxy.js +119 -0
- package/static/build/shared/utils.js +2 -1
- package/static/build/token.js +3 -14
- package/static/build/validation/schedule.js +6 -12
- 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/292.264757f0.async.js +1 -0
- package/static/dist/3512.95e41255.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/{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.01fcd534.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.0b8cce8c.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.0fa8b421.async.js +1 -0
- package/static/dist/src__pages__diff__index.b94e5dc5.async.js +1 -0
- 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.afabf073.async.js +1 -0
- package/static/dist/src__pages__script__editNameModal.789ad87b.async.js +1 -0
- package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js +1 -0
- package/static/dist/src__pages__script__historyDrawer.a449193a.chunk.css +1 -0
- package/static/dist/src__pages__script__index.ab360776.chunk.css +1 -0
- package/static/dist/src__pages__script__index.fc575945.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
- package/static/dist/src__pages__script__saveModal.8fca1a22.async.js +1 -0
- package/static/dist/src__pages__script__saveWithHistory.99ece830.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.d175b154.async.js +1 -0
- 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.30868ba8.async.js +1 -0
- package/static/dist/{umi.ca04a019.js → umi.3a24a9fa.js} +1 -1
- package/test/back/advisory-input-security.test.cjs +416 -0
- package/test/back/auth-security.test.cjs +74 -0
- package/test/back/build-provenance.test.cjs +150 -0
- package/test/back/code-scanning-security.test.cjs +189 -0
- package/test/back/cron-log-name.test.cjs +110 -0
- package/test/back/cron-macros.test.cjs +51 -0
- package/test/back/cron-schedule-compatibility.test.cjs +69 -0
- package/test/back/cron-scheduler-routing.test.cjs +59 -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/draft-path-security.test.cjs +235 -0
- package/test/back/ecosystem.test.cjs +28 -0
- package/test/back/env-import-security.test.cjs +91 -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-scope.test.cjs +180 -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/grpc-mtls-security.test.cjs +136 -0
- package/test/back/http-exclusive-listen.test.cjs +31 -0
- package/test/back/http-security.test.cjs +313 -0
- package/test/back/legacy-cron-recovery.test.cjs +76 -0
- package/test/back/linux-mirror-result.test.cjs +176 -0
- package/test/back/listen-security.test.cjs +68 -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/mirror-status.test.cjs +257 -0
- package/test/back/monitoring.test.cjs +73 -0
- package/test/back/node-cron-migration.test.cjs +65 -0
- package/test/back/node-path-cache.test.cjs +202 -0
- package/test/back/node-path-lock.test.cjs +182 -0
- package/test/back/npm-publication.test.cjs +70 -0
- package/test/back/preload-lazy-notify.test.cjs +168 -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/queued-cron-invalidation.test.cjs +98 -0
- package/test/back/restart-instance-recovery.test.cjs +116 -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-bulk-recovery.test.cjs +40 -0
- package/test/back/scheduler-concurrency.test.cjs +411 -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 +206 -0
- package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
- package/test/back/schema-migrations.test.cjs +127 -0
- package/test/back/script-file-access.test.cjs +210 -0
- package/test/back/script-history-api.test.cjs +551 -0
- package/test/back/script-history.test.cjs +383 -0
- package/test/back/shell-api-parsing.test.cjs +184 -0
- package/test/back/shell-translation-output.test.cjs +16 -0
- package/test/back/shell-upgrade.test.cjs +312 -0
- package/test/back/shellApiToken.test.cjs +151 -0
- package/test/back/sock-polling.test.cjs +297 -0
- package/test/back/sock-security.test.cjs +72 -0
- package/test/back/ssh-config-home.test.cjs +113 -0
- package/test/back/start-env-preservation.test.cjs +53 -0
- package/test/back/static-mirror-trigger.test.cjs +441 -0
- package/test/back/static-mirror.test.cjs +179 -0
- package/test/back/stop-failure-feedback.test.cjs +158 -0
- package/test/back/stop-race.test.cjs +171 -0
- package/test/back/subscription-cleanup.test.cjs +53 -0
- package/test/back/subscription-mutation-lock.test.cjs +83 -0
- package/test/back/subscription-review-regression.test.cjs +607 -0
- package/test/back/subscription-stop-state.test.cjs +66 -0
- package/test/back/subscription-storage-regression.test.cjs +553 -0
- package/test/back/system-dependence-cache.test.cjs +127 -0
- package/test/back/system-export-history.test.cjs +119 -0
- package/test/back/systemTokenRenewal.test.cjs +497 -0
- package/test/back/task-shell-lifecycle.test.cjs +194 -0
- package/test/back/task-time.test.cjs +116 -0
- package/test/back/unique-constraint-error.test.cjs +72 -0
- package/test/back/upgrade-guards.test.cjs +285 -0
- package/test/back/upgrade-lifecycle.test.cjs +288 -0
- package/test/back/upgrade-transaction.test.cjs +133 -0
- package/test/back/user-api.test.cjs +99 -0
- package/test/back/user-security.test.cjs +349 -0
- package/test/back/worker-apm.test.cjs +84 -0
- package/test/back/wpush-grpc.test.cjs +116 -0
- package/test/fixtures/legacy-cron.json +1371 -0
- package/test/front/cron-log-pagination.test.cjs +214 -0
- package/test/front/diff-file-routing.test.cjs +126 -0
- package/test/front/http-auth.test.cjs +152 -0
- package/test/front/http-error.test.cjs +29 -0
- package/test/front/script-history-save.test.cjs +121 -0
- package/test/helpers/load-security-module.cjs +42 -0
- package/test/helpers/upgrade-fixture.cjs +30 -0
- package/version.yaml +14 -34
- package/CLAUDE.md +0 -43
- package/static/dist/1147.c420132e.async.js +0 -1
- package/static/dist/134.54df9e38.async.js +0 -1
- package/static/dist/2096.6d98fd12.async.js +0 -1
- package/static/dist/2208.f7ba3dfa.async.js +0 -1
- package/static/dist/2286.164bb089.async.js +0 -1
- package/static/dist/3191.63263871.async.js +0 -1
- package/static/dist/4859.6592cebb.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/6707.801b886b.async.js +0 -1
- package/static/dist/8826.2447a104.async.js +0 -1
- package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
- package/static/dist/preload_helper.0431c0f3.js +0 -1
- package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
- package/static/dist/src__pages__crontab__index.fed99fd0.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.b30f2f47.async.js +0 -1
- package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
- package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
- package/static/dist/src__pages__diff__index.013b7c75.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
- package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
- package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
- package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
- package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
- package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
- package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
- package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
- package/static/dist/src__pages__script__index.60b6f827.chunk.css +0 -1
- package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
- package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
- package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
- package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
- package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
- package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
- package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
- package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
- package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
- package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
- package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
- package/static/dist/src__pages__setting__systemLog.67406721.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.3562c670.async.js +0 -1
- /package/static/dist/{4859.1b962b29.chunk.css → 292.1b962b29.chunk.css} +0 -0
|
@@ -38,6 +38,7 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
38
38
|
const pLimit_1 = __importDefault(require("../shared/pLimit"));
|
|
39
39
|
const util_2 = require("../config/util");
|
|
40
40
|
const const_1 = require("../config/const");
|
|
41
|
+
const i18n_1 = require("../shared/i18n");
|
|
41
42
|
let DependenceService = class DependenceService {
|
|
42
43
|
constructor(logger, sockService) {
|
|
43
44
|
this.logger = logger;
|
|
@@ -87,6 +88,10 @@ let DependenceService = class DependenceService {
|
|
|
87
88
|
}
|
|
88
89
|
async dependencies({ searchValue, type, status, }, sort = [], query = {}) {
|
|
89
90
|
let condition = query;
|
|
91
|
+
const dependenceType = type && dependence_1.DependenceTypes[type] !== undefined
|
|
92
|
+
? dependence_1.DependenceTypes[type]
|
|
93
|
+
: undefined;
|
|
94
|
+
await this.refreshInstalledStatuses(dependenceType);
|
|
90
95
|
if (type && dependence_1.DependenceTypes[type] !== undefined) {
|
|
91
96
|
condition.type = dependence_1.DependenceTypes[type];
|
|
92
97
|
}
|
|
@@ -109,6 +114,49 @@ let DependenceService = class DependenceService {
|
|
|
109
114
|
throw error;
|
|
110
115
|
}
|
|
111
116
|
}
|
|
117
|
+
async refreshInstalledStatuses(type) {
|
|
118
|
+
const cacheDependenceTypes = [
|
|
119
|
+
dependence_1.DependenceTypes.nodejs,
|
|
120
|
+
dependence_1.DependenceTypes.python3,
|
|
121
|
+
];
|
|
122
|
+
if (type !== undefined && !cacheDependenceTypes.includes(type)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const docs = await dependence_1.DependenceModel.findAll({
|
|
126
|
+
where: {
|
|
127
|
+
status: dependence_1.DependenceStatus.installed,
|
|
128
|
+
type: type === undefined ? { [sequelize_1.Op.in]: cacheDependenceTypes } : type,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
const checks = await (0, util_1.concurrentRun)(docs.map((doc) => async () => {
|
|
132
|
+
return (await this.isDependenceInstalled(doc)) ? undefined : doc.id;
|
|
133
|
+
}), 5);
|
|
134
|
+
const missingIds = (checks || []).filter((id) => id !== undefined);
|
|
135
|
+
if (missingIds.length) {
|
|
136
|
+
await dependence_1.DependenceModel.update({ status: dependence_1.DependenceStatus.installFailed }, { where: { id: missingIds } });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async isDependenceInstalled(dependency) {
|
|
140
|
+
var _a;
|
|
141
|
+
let depName = dependency.name.trim();
|
|
142
|
+
const depVersionStr = dependence_1.versionDependenceCommandTypes[dependency.type];
|
|
143
|
+
let depVersion = '';
|
|
144
|
+
if (depName.includes(depVersionStr)) {
|
|
145
|
+
const symbolRegx = new RegExp(`(.*)${depVersionStr}([0-9\\.\\-\\+a-zA-Z]*)`);
|
|
146
|
+
const [, parsedName, parsedVersion] = depName.match(symbolRegx) || [];
|
|
147
|
+
if (parsedVersion && parsedName) {
|
|
148
|
+
depName = parsedName;
|
|
149
|
+
depVersion = parsedVersion;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const depInfo = (await (0, util_1.promiseExecSuccess)((0, util_1.getGetCommand)(dependency.type, depName)))
|
|
153
|
+
.replace(/\s{2,}/, ' ')
|
|
154
|
+
.replace(/\s+$/, '');
|
|
155
|
+
const nameMatches = (dependency.type === dependence_1.DependenceTypes.nodejs &&
|
|
156
|
+
((_a = depInfo.split(' ')) === null || _a === void 0 ? void 0 : _a[0]) === depName) ||
|
|
157
|
+
dependency.type === dependence_1.DependenceTypes.python3;
|
|
158
|
+
return Boolean(depInfo && nameMatches && (!depVersion || depInfo.includes(depVersion)));
|
|
159
|
+
}
|
|
112
160
|
installDependenceOneByOne(docs, isInstall = true, force = false) {
|
|
113
161
|
docs.forEach((dep) => {
|
|
114
162
|
this.installOrUninstallDependency(dep, isInstall, force);
|
|
@@ -183,7 +231,7 @@ let DependenceService = class DependenceService {
|
|
|
183
231
|
}
|
|
184
232
|
const depIds = [dependency.id];
|
|
185
233
|
let depName = dependency.name.trim();
|
|
186
|
-
const actionText = isInstall ? '安装' : '删除';
|
|
234
|
+
const actionText = isInstall ? (0, i18n_1.t)('安装') : (0, i18n_1.t)('删除');
|
|
187
235
|
const socketMessageType = isInstall
|
|
188
236
|
? 'installDependence'
|
|
189
237
|
: 'uninstallDependence';
|
|
@@ -197,11 +245,12 @@ let DependenceService = class DependenceService {
|
|
|
197
245
|
if (!osType) {
|
|
198
246
|
await dependence_1.DependenceModel.update({ status: dependence_1.DependenceStatus.installFailed }, { where: { id: depIds } });
|
|
199
247
|
const startTime = (0, dayjs_1.default)();
|
|
200
|
-
const message =
|
|
248
|
+
const message = (0, i18n_1.tf)('开始%s依赖 %s,开始时间 %s\n\n当前系统不支持\n\n依赖%s失败,结束时间 %s,耗时 %s 秒', actionText, depName, startTime.format('YYYY-MM-DD HH:mm:ss'), actionText, startTime.format('YYYY-MM-DD HH:mm:ss'), String(startTime.diff(startTime, 'second')));
|
|
201
249
|
this.sockService.sendMessage({
|
|
202
250
|
type: socketMessageType,
|
|
203
251
|
message,
|
|
204
252
|
references: depIds,
|
|
253
|
+
status: dependence_1.DependenceStatus.installFailed,
|
|
205
254
|
});
|
|
206
255
|
this.updateLog(depIds, message);
|
|
207
256
|
return resolve(null);
|
|
@@ -221,11 +270,12 @@ let DependenceService = class DependenceService {
|
|
|
221
270
|
: `${linuxCommand.uninstall} ${depName.trim()}`;
|
|
222
271
|
}
|
|
223
272
|
const startTime = (0, dayjs_1.default)();
|
|
224
|
-
const message =
|
|
273
|
+
const message = (0, i18n_1.tf)('开始%s依赖 %s,开始时间 %s\n\n', actionText, depName, startTime.format('YYYY-MM-DD HH:mm:ss'));
|
|
225
274
|
this.sockService.sendMessage({
|
|
226
275
|
type: socketMessageType,
|
|
227
276
|
message,
|
|
228
277
|
references: depIds,
|
|
278
|
+
status,
|
|
229
279
|
});
|
|
230
280
|
this.updateLog(depIds, message);
|
|
231
281
|
// 判断是否已经安装过依赖
|
|
@@ -254,11 +304,12 @@ let DependenceService = class DependenceService {
|
|
|
254
304
|
isPythonDependence) &&
|
|
255
305
|
(!depVersion || depInfo.includes(depVersion))) {
|
|
256
306
|
const endTime = (0, dayjs_1.default)();
|
|
257
|
-
const _message =
|
|
307
|
+
const _message = (0, i18n_1.tf)('检测到已经安装 %s\n\n%s\n\n跳过安装\n\n依赖%s成功,结束时间 %s,耗时 %s 秒', depName, depInfo, actionText, endTime.format('YYYY-MM-DD HH:mm:ss'), String(endTime.diff(startTime, 'second')));
|
|
258
308
|
this.sockService.sendMessage({
|
|
259
309
|
type: socketMessageType,
|
|
260
310
|
message: _message,
|
|
261
311
|
references: depIds,
|
|
312
|
+
status: dependence_1.DependenceStatus.installed,
|
|
262
313
|
});
|
|
263
314
|
this.updateLog(depIds, _message);
|
|
264
315
|
await dependence_1.DependenceModel.update({ status: dependence_1.DependenceStatus.installed }, { where: { id: depIds } });
|
|
@@ -277,6 +328,7 @@ let DependenceService = class DependenceService {
|
|
|
277
328
|
type: socketMessageType,
|
|
278
329
|
message: data.toString(),
|
|
279
330
|
references: depIds,
|
|
331
|
+
status,
|
|
280
332
|
});
|
|
281
333
|
this.updateLog(depIds, data.toString());
|
|
282
334
|
});
|
|
@@ -285,6 +337,7 @@ let DependenceService = class DependenceService {
|
|
|
285
337
|
type: socketMessageType,
|
|
286
338
|
message: data.toString(),
|
|
287
339
|
references: depIds,
|
|
340
|
+
status,
|
|
288
341
|
});
|
|
289
342
|
this.updateLog(depIds, data.toString());
|
|
290
343
|
});
|
|
@@ -293,37 +346,32 @@ let DependenceService = class DependenceService {
|
|
|
293
346
|
type: socketMessageType,
|
|
294
347
|
message: JSON.stringify(err),
|
|
295
348
|
references: depIds,
|
|
349
|
+
status,
|
|
296
350
|
});
|
|
297
351
|
this.updateLog(depIds, JSON.stringify(err));
|
|
298
352
|
});
|
|
299
353
|
cp.on('exit', async (code) => {
|
|
300
354
|
const endTime = (0, dayjs_1.default)();
|
|
301
355
|
const isSucceed = code === 0;
|
|
302
|
-
const resultText = isSucceed ? '成功' : '失败';
|
|
303
|
-
const message =
|
|
356
|
+
const resultText = isSucceed ? (0, i18n_1.t)('成功') : (0, i18n_1.t)('失败');
|
|
357
|
+
const message = '\n' +
|
|
358
|
+
(0, i18n_1.tf)('依赖%s%s,结束时间 %s,耗时 %s 秒', actionText, resultText, endTime.format('YYYY-MM-DD HH:mm:ss'), String(endTime.diff(startTime, 'second')));
|
|
359
|
+
const exitStatus = isSucceed
|
|
360
|
+
? (isInstall ? dependence_1.DependenceStatus.installed : dependence_1.DependenceStatus.removed)
|
|
361
|
+
: (isInstall ? dependence_1.DependenceStatus.installFailed : dependence_1.DependenceStatus.removeFailed);
|
|
304
362
|
this.sockService.sendMessage({
|
|
305
363
|
type: socketMessageType,
|
|
306
364
|
message,
|
|
307
365
|
references: depIds,
|
|
366
|
+
status: exitStatus,
|
|
308
367
|
});
|
|
309
368
|
this.updateLog(depIds, message);
|
|
310
|
-
let status;
|
|
311
|
-
if (isSucceed) {
|
|
312
|
-
status = isInstall
|
|
313
|
-
? dependence_1.DependenceStatus.installed
|
|
314
|
-
: dependence_1.DependenceStatus.removed;
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
status = isInstall
|
|
318
|
-
? dependence_1.DependenceStatus.installFailed
|
|
319
|
-
: dependence_1.DependenceStatus.removeFailed;
|
|
320
|
-
}
|
|
321
369
|
const docs = await dependence_1.DependenceModel.findAll({ where: { id: depIds } });
|
|
322
370
|
const _docIds = docs
|
|
323
371
|
.filter((x) => x.status !== dependence_1.DependenceStatus.cancelled)
|
|
324
372
|
.map((x) => x.id);
|
|
325
373
|
if (_docIds.length > 0) {
|
|
326
|
-
await dependence_1.DependenceModel.update({ status }, { where: { id: _docIds } });
|
|
374
|
+
await dependence_1.DependenceModel.update({ status: exitStatus }, { where: { id: _docIds } });
|
|
327
375
|
}
|
|
328
376
|
// 如果删除依赖成功或者强制删除
|
|
329
377
|
if ((isSucceed || force) && !isInstall) {
|
|
@@ -223,7 +223,7 @@ let EnvService = class EnvService {
|
|
|
223
223
|
.map((x) => x.value)
|
|
224
224
|
.join('&')
|
|
225
225
|
.replace(/\\/g, '\\\\')}`;
|
|
226
|
-
js_env_string += `process.env
|
|
226
|
+
js_env_string += `process.env[${JSON.stringify(key)}]=${JSON.stringify(group.map((x) => x.value).join('&'))};\n`;
|
|
227
227
|
py_env_string += `os.environ['${key}']='''${_env_value.replace(/\'/g, "\\'")}'''\n`;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -39,6 +39,7 @@ const health_1 = require("../protos/health");
|
|
|
39
39
|
const api_1 = require("../protos/api");
|
|
40
40
|
const addCron_1 = require("../schedule/addCron");
|
|
41
41
|
const delCron_1 = require("../schedule/delCron");
|
|
42
|
+
const setConcurrency_1 = require("../schedule/setConcurrency");
|
|
42
43
|
const health_2 = require("../schedule/health");
|
|
43
44
|
const Api = __importStar(require("../schedule/api"));
|
|
44
45
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
@@ -60,14 +61,14 @@ let GrpcServerService = class GrpcServerService {
|
|
|
60
61
|
async initialize() {
|
|
61
62
|
try {
|
|
62
63
|
this.server.addService(health_1.HealthService, { check: health_2.check });
|
|
63
|
-
this.server.addService(cron_1.CronService, { addCron: addCron_1.addCron, delCron: delCron_1.delCron });
|
|
64
|
+
this.server.addService(cron_1.CronService, { addCron: addCron_1.addCron, delCron: delCron_1.delCron, setConcurrency: setConcurrency_1.setConcurrency });
|
|
64
65
|
this.server.addService(api_1.ApiService, Api);
|
|
65
66
|
const tlsConfig = await (0, grpcCerts_1.initGrpcCerts)();
|
|
66
67
|
const credentials = grpc_js_1.ServerCredentials.createSsl(Buffer.from(tlsConfig.caCert), [{ cert_chain: Buffer.from(tlsConfig.serverCert), private_key: Buffer.from(tlsConfig.serverKey) }], true);
|
|
67
68
|
const grpcPort = config_1.default.grpcPort;
|
|
68
69
|
const hostsToTry = [
|
|
69
70
|
config_1.default.bindHostGrpc,
|
|
70
|
-
...(config_1.default.bindHostGrpc
|
|
71
|
+
...(config_1.default.bindHostGrpc === '::' ? ['0.0.0.0'] : [])
|
|
71
72
|
];
|
|
72
73
|
const bindAsync = (0, util_1.promisify)(this.server.bindAsync).bind(this.server);
|
|
73
74
|
let lastError = null;
|
|
@@ -75,7 +76,7 @@ let GrpcServerService = class GrpcServerService {
|
|
|
75
76
|
try {
|
|
76
77
|
const address = this.formatGrpcAddress(host, grpcPort);
|
|
77
78
|
await bindAsync(address, credentials);
|
|
78
|
-
logger_1.default.debug(
|
|
79
|
+
logger_1.default.debug(`[boot] gRPC service started successfully on ${address}`);
|
|
79
80
|
metrics_1.metricsService.record('grpc_service_start', 1, {
|
|
80
81
|
port: grpcPort.toString(),
|
|
81
82
|
host
|
|
@@ -15,11 +15,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.HealthService = void 0;
|
|
16
16
|
const typedi_1 = require("typedi");
|
|
17
17
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
18
|
-
const
|
|
18
|
+
const client_1 = __importDefault(require("../schedule/client"));
|
|
19
19
|
const http_1 = require("./http");
|
|
20
20
|
let HealthService = class HealthService {
|
|
21
|
-
constructor(
|
|
22
|
-
this.grpcServerService = grpcServerService;
|
|
21
|
+
constructor(httpServerService) {
|
|
23
22
|
this.httpServerService = httpServerService;
|
|
24
23
|
this.startTime = Date.now();
|
|
25
24
|
}
|
|
@@ -51,8 +50,7 @@ let HealthService = class HealthService {
|
|
|
51
50
|
logger_1.default.error('HTTP server check failed:', err);
|
|
52
51
|
}
|
|
53
52
|
try {
|
|
54
|
-
|
|
55
|
-
if (!grpcServer) {
|
|
53
|
+
if (!(await client_1.default.readiness.check())) {
|
|
56
54
|
status.services.grpc = false;
|
|
57
55
|
status.status = 'error';
|
|
58
56
|
}
|
|
@@ -68,7 +66,6 @@ let HealthService = class HealthService {
|
|
|
68
66
|
exports.HealthService = HealthService;
|
|
69
67
|
exports.HealthService = HealthService = __decorate([
|
|
70
68
|
(0, typedi_1.Service)(),
|
|
71
|
-
__metadata("design:paramtypes", [
|
|
72
|
-
http_1.HttpServerService])
|
|
69
|
+
__metadata("design:paramtypes", [http_1.HttpServerService])
|
|
73
70
|
], HealthService);
|
|
74
71
|
//# sourceMappingURL=health.js.map
|
|
@@ -21,13 +21,13 @@ let HttpServerService = class HttpServerService {
|
|
|
21
21
|
async initialize(expressApp, port) {
|
|
22
22
|
const hostsToTry = [
|
|
23
23
|
config_1.default.bindHost,
|
|
24
|
-
...(config_1.default.bindHost
|
|
24
|
+
...(config_1.default.bindHost === '::' ? ['0.0.0.0'] : [])
|
|
25
25
|
];
|
|
26
26
|
let lastError = null;
|
|
27
27
|
for (const host of hostsToTry) {
|
|
28
28
|
try {
|
|
29
29
|
const server = await this.tryListen(expressApp, port, host);
|
|
30
|
-
logger_1.default.debug(
|
|
30
|
+
logger_1.default.debug(`[boot] HTTP service started successfully on ${host}:${port}`);
|
|
31
31
|
metrics_1.metricsService.record('http_service_start', 1, {
|
|
32
32
|
port: port.toString(),
|
|
33
33
|
host
|
|
@@ -45,7 +45,13 @@ let HttpServerService = class HttpServerService {
|
|
|
45
45
|
}
|
|
46
46
|
async tryListen(expressApp, port, host) {
|
|
47
47
|
return new Promise((resolve, reject) => {
|
|
48
|
-
|
|
48
|
+
// There is one HTTP worker; accepting here avoids primary IPC handoff
|
|
49
|
+
// for every connection. Restore shared listening for custom clusters.
|
|
50
|
+
const server = expressApp.listen({
|
|
51
|
+
port,
|
|
52
|
+
host,
|
|
53
|
+
exclusive: process.env.QL_HTTP_SHARED_LISTEN !== 'true',
|
|
54
|
+
}, () => {
|
|
49
55
|
resolve(server);
|
|
50
56
|
});
|
|
51
57
|
server.on('error', (err) => {
|
|
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const
|
|
18
|
+
const fileAccess_1 = require("../shared/fileAccess");
|
|
19
19
|
const typedi_1 = require("typedi");
|
|
20
20
|
const winston_1 = __importDefault(require("winston"));
|
|
21
21
|
const config_1 = __importDefault(require("../config"));
|
|
@@ -24,8 +24,7 @@ let LogService = class LogService {
|
|
|
24
24
|
this.logger = logger;
|
|
25
25
|
}
|
|
26
26
|
checkFilePath(filePath, fileName) {
|
|
27
|
-
|
|
28
|
-
return finalPath.startsWith(config_1.default.logPath) ? finalPath : '';
|
|
27
|
+
return (0, fileAccess_1.resolveFileAccess)(config_1.default.logPath, [filePath || '', fileName]);
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
30
|
LogService = __decorate([
|
|
@@ -3,17 +3,19 @@ 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.metricsService = void 0;
|
|
6
|
+
exports.metricsService = exports.MetricsService = exports.MAX_METRIC_SAMPLES = void 0;
|
|
7
7
|
const perf_hooks_1 = require("perf_hooks");
|
|
8
8
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
9
|
+
exports.MAX_METRIC_SAMPLES = 1000;
|
|
10
|
+
const METRIC_RETENTION_MS = 60 * 60 * 1000;
|
|
9
11
|
class MetricsService {
|
|
10
12
|
constructor() {
|
|
11
|
-
this.metrics =
|
|
13
|
+
this.metrics = new Array(exports.MAX_METRIC_SAMPLES);
|
|
14
|
+
this.metricCount = 0;
|
|
15
|
+
this.nextMetricIndex = 0;
|
|
12
16
|
// 定期清理旧数据
|
|
13
|
-
setInterval(() =>
|
|
14
|
-
|
|
15
|
-
this.metrics = this.metrics.filter(m => m.timestamp > oneHourAgo);
|
|
16
|
-
}, 60000);
|
|
17
|
+
const cleanupTimer = setInterval(() => this.removeExpiredMetrics(), 60000);
|
|
18
|
+
cleanupTimer.unref();
|
|
17
19
|
}
|
|
18
20
|
static getInstance() {
|
|
19
21
|
if (!MetricsService.instance) {
|
|
@@ -22,12 +24,14 @@ class MetricsService {
|
|
|
22
24
|
return MetricsService.instance;
|
|
23
25
|
}
|
|
24
26
|
record(name, value, tags) {
|
|
25
|
-
this.metrics.
|
|
27
|
+
this.metrics[this.nextMetricIndex] = {
|
|
26
28
|
name,
|
|
27
29
|
value,
|
|
28
30
|
timestamp: Date.now(),
|
|
29
31
|
tags,
|
|
30
|
-
}
|
|
32
|
+
};
|
|
33
|
+
this.nextMetricIndex = (this.nextMetricIndex + 1) % exports.MAX_METRIC_SAMPLES;
|
|
34
|
+
this.metricCount = Math.min(this.metricCount + 1, exports.MAX_METRIC_SAMPLES);
|
|
31
35
|
}
|
|
32
36
|
measure(name, fn, tags) {
|
|
33
37
|
const start = perf_hooks_1.performance.now();
|
|
@@ -50,25 +54,52 @@ class MetricsService {
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
getMetrics(name, tags) {
|
|
53
|
-
|
|
57
|
+
this.removeExpiredMetrics();
|
|
58
|
+
let filtered = this.getMetricSnapshot();
|
|
54
59
|
if (name) {
|
|
55
|
-
filtered = filtered.filter(m => m.name === name);
|
|
60
|
+
filtered = filtered.filter((m) => m.name === name);
|
|
56
61
|
}
|
|
57
62
|
if (tags) {
|
|
58
|
-
filtered = filtered.filter(m => {
|
|
63
|
+
filtered = filtered.filter((m) => {
|
|
59
64
|
if (!m.tags)
|
|
60
65
|
return false;
|
|
61
66
|
return Object.entries(tags).every(([key, value]) => m.tags[key] === value);
|
|
62
67
|
});
|
|
63
68
|
}
|
|
69
|
+
const values = filtered.map((metric) => metric.value);
|
|
64
70
|
return {
|
|
65
71
|
count: filtered.length,
|
|
66
|
-
average:
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
average: values.length
|
|
73
|
+
? values.reduce((acc, value) => acc + value, 0) / values.length
|
|
74
|
+
: 0,
|
|
75
|
+
min: values.length ? Math.min(...values) : 0,
|
|
76
|
+
max: values.length ? Math.max(...values) : 0,
|
|
69
77
|
metrics: filtered,
|
|
70
78
|
};
|
|
71
79
|
}
|
|
80
|
+
getMetricSnapshot() {
|
|
81
|
+
if (this.metricCount < exports.MAX_METRIC_SAMPLES) {
|
|
82
|
+
return this.metrics.slice(0, this.metricCount);
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
...this.metrics.slice(this.nextMetricIndex),
|
|
86
|
+
...this.metrics.slice(0, this.nextMetricIndex),
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
removeExpiredMetrics() {
|
|
90
|
+
const oldestTimestamp = Date.now() - METRIC_RETENTION_MS;
|
|
91
|
+
const retained = this.getMetricSnapshot().filter((metric) => metric.timestamp > oldestTimestamp);
|
|
92
|
+
if (retained.length === this.metricCount)
|
|
93
|
+
return;
|
|
94
|
+
this.metrics = new Array(exports.MAX_METRIC_SAMPLES);
|
|
95
|
+
this.metricCount = 0;
|
|
96
|
+
this.nextMetricIndex = 0;
|
|
97
|
+
for (const metric of retained) {
|
|
98
|
+
this.metrics[this.nextMetricIndex] = metric;
|
|
99
|
+
this.nextMetricIndex = (this.nextMetricIndex + 1) % exports.MAX_METRIC_SAMPLES;
|
|
100
|
+
this.metricCount++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
72
103
|
report() {
|
|
73
104
|
const report = {
|
|
74
105
|
timestamp: Date.now(),
|
|
@@ -78,5 +109,6 @@ class MetricsService {
|
|
|
78
109
|
return report;
|
|
79
110
|
}
|
|
80
111
|
}
|
|
112
|
+
exports.MetricsService = MetricsService;
|
|
81
113
|
exports.metricsService = MetricsService.getInstance();
|
|
82
114
|
//# sourceMappingURL=metrics.js.map
|
|
@@ -55,7 +55,9 @@ let NotificationService = class NotificationService {
|
|
|
55
55
|
['chronocat', this.chronocat],
|
|
56
56
|
['ntfy', this.ntfy],
|
|
57
57
|
['wxPusherBot', this.wxPusherBot],
|
|
58
|
+
['wxPusherSpt', this.wxPusherSpt],
|
|
58
59
|
['openiLink', this.openiLink],
|
|
60
|
+
['wpush', this.wpush],
|
|
59
61
|
]);
|
|
60
62
|
this.title = '';
|
|
61
63
|
this.content = '';
|
|
@@ -306,7 +308,7 @@ let NotificationService = class NotificationService {
|
|
|
306
308
|
{
|
|
307
309
|
title: `${this.title}`,
|
|
308
310
|
thumb_media_id,
|
|
309
|
-
author:
|
|
311
|
+
author: (0, i18n_1.t)('智能助手'),
|
|
310
312
|
content_source_url: ``,
|
|
311
313
|
content: `${this.content.replace(/\n/g, '<br/>')}`,
|
|
312
314
|
digest: `${this.content}`,
|
|
@@ -322,7 +324,7 @@ let NotificationService = class NotificationService {
|
|
|
322
324
|
title: `${this.title}`,
|
|
323
325
|
description: `${this.content}`,
|
|
324
326
|
url: 'https://github.com/whyour/qinglong',
|
|
325
|
-
btntxt: '更多',
|
|
327
|
+
btntxt: (0, i18n_1.t)('更多'),
|
|
326
328
|
},
|
|
327
329
|
};
|
|
328
330
|
break;
|
|
@@ -361,7 +363,7 @@ let NotificationService = class NotificationService {
|
|
|
361
363
|
roomName: `${aibotkName}`,
|
|
362
364
|
message: {
|
|
363
365
|
type: 1,
|
|
364
|
-
content:
|
|
366
|
+
content: `【${(0, i18n_1.t)('青龙快讯')}】\n\n${this.title}\n${this.content}`,
|
|
365
367
|
},
|
|
366
368
|
};
|
|
367
369
|
break;
|
|
@@ -372,7 +374,7 @@ let NotificationService = class NotificationService {
|
|
|
372
374
|
name: `${aibotkName}`,
|
|
373
375
|
message: {
|
|
374
376
|
type: 1,
|
|
375
|
-
content:
|
|
377
|
+
content: `【${(0, i18n_1.t)('青龙快讯')}】\n\n${this.title}\n${this.content}`,
|
|
376
378
|
},
|
|
377
379
|
};
|
|
378
380
|
break;
|
|
@@ -507,7 +509,7 @@ let NotificationService = class NotificationService {
|
|
|
507
509
|
},
|
|
508
510
|
});
|
|
509
511
|
const info = await transporter.sendMail({
|
|
510
|
-
from: `"青龙快讯" <${emailUser}>`,
|
|
512
|
+
from: `"${(0, i18n_1.t)('青龙快讯')}" <${emailUser}>`,
|
|
511
513
|
to: recipients,
|
|
512
514
|
subject: `${this.title}`,
|
|
513
515
|
html: `${this.content.replace(/\n/g, '<br/>')}`,
|
|
@@ -620,6 +622,47 @@ let NotificationService = class NotificationService {
|
|
|
620
622
|
throw new Error(error.response ? error.response.body : error);
|
|
621
623
|
}
|
|
622
624
|
}
|
|
625
|
+
async wxPusherSpt() {
|
|
626
|
+
const { wxPusherSptList } = this.params;
|
|
627
|
+
// 处理 SPT,将逗号分隔的字符串转为数组
|
|
628
|
+
const spts = wxPusherSptList
|
|
629
|
+
? wxPusherSptList
|
|
630
|
+
.split(',')
|
|
631
|
+
.map((spt) => spt.trim())
|
|
632
|
+
.filter((spt) => spt)
|
|
633
|
+
: [];
|
|
634
|
+
if (!spts.length) {
|
|
635
|
+
throw new Error((0, i18n_1.t)('wxPusher SPT 不能为空'));
|
|
636
|
+
}
|
|
637
|
+
if (spts.length > 10) {
|
|
638
|
+
throw new Error((0, i18n_1.t)('wxPusher SPT 最多支持 10 个'));
|
|
639
|
+
}
|
|
640
|
+
const url = `https://wxpusher.zjiecode.com/api/send/message/simple-push`;
|
|
641
|
+
const json = {
|
|
642
|
+
content: `<h1>${this.title}</h1><br/><div style='white-space: pre-wrap;'>${this.content}</div>`,
|
|
643
|
+
summary: this.title,
|
|
644
|
+
contentType: 2,
|
|
645
|
+
};
|
|
646
|
+
// 单个 SPT 用 spt,多个用 sptList
|
|
647
|
+
if (spts.length === 1) {
|
|
648
|
+
json.spt = spts[0];
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
json.sptList = spts;
|
|
652
|
+
}
|
|
653
|
+
try {
|
|
654
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json }));
|
|
655
|
+
if (res.code === 1000) {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
throw new Error(JSON.stringify(res));
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch (error) {
|
|
663
|
+
throw new Error(error.response ? error.response.body : error);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
623
666
|
async chronocat() {
|
|
624
667
|
var _a, _b;
|
|
625
668
|
const { chronocatURL, chronocatQQ, chronocatToken } = this.params;
|
|
@@ -737,6 +780,31 @@ let NotificationService = class NotificationService {
|
|
|
737
780
|
throw new Error(error.response ? error.response.body : error);
|
|
738
781
|
}
|
|
739
782
|
}
|
|
783
|
+
async wpush() {
|
|
784
|
+
const { wpushApiKey, wpushChannel, wpushTopicCode } = this.params;
|
|
785
|
+
const url = 'https://api.wpush.cn/api/v1/send';
|
|
786
|
+
const json = {
|
|
787
|
+
apikey: `${wpushApiKey}`,
|
|
788
|
+
title: `${this.title}`,
|
|
789
|
+
content: `${this.content}`,
|
|
790
|
+
channel: `${wpushChannel || 'wechat'}`,
|
|
791
|
+
};
|
|
792
|
+
if (wpushTopicCode) {
|
|
793
|
+
json.topic_code = `${wpushTopicCode}`;
|
|
794
|
+
}
|
|
795
|
+
try {
|
|
796
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json }));
|
|
797
|
+
if (res.code === 0) {
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
throw new Error(JSON.stringify(res));
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
catch (error) {
|
|
805
|
+
throw new Error(error.response ? error.response.body : error);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
740
808
|
};
|
|
741
809
|
__decorate([
|
|
742
810
|
(0, typedi_1.Inject)((type) => user_1.default),
|