@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
|
@@ -98,7 +98,11 @@ function run() {
|
|
|
98
98
|
const newEnvObject = JSON.parse(envStr);
|
|
99
99
|
if (typeof newEnvObject === 'object' && newEnvObject !== null) {
|
|
100
100
|
for (const key in newEnvObject) {
|
|
101
|
-
if (
|
|
101
|
+
if (
|
|
102
|
+
Object.prototype.hasOwnProperty.call(newEnvObject, key) &&
|
|
103
|
+
key !== 'NODE_PATH' &&
|
|
104
|
+
key !== 'QL_NODE_GLOBAL_PATH'
|
|
105
|
+
) {
|
|
102
106
|
process.env[key] = newEnvObject[key];
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -155,9 +159,13 @@ try {
|
|
|
155
159
|
|
|
156
160
|
run();
|
|
157
161
|
|
|
158
|
-
const { sendNotify } = require('./__ql_notify__.js');
|
|
159
162
|
global.QLAPI = {
|
|
160
|
-
notify
|
|
163
|
+
notify(...args) {
|
|
164
|
+
// Keep notification dependencies out of ordinary script startup.
|
|
165
|
+
// require caches the module after the first notification.
|
|
166
|
+
const { sendNotify } = require('./__ql_notify__.js');
|
|
167
|
+
return sendNotify.apply(this, args);
|
|
168
|
+
},
|
|
161
169
|
...client,
|
|
162
170
|
};
|
|
163
171
|
} catch (error) {
|
|
@@ -129,10 +129,12 @@ try:
|
|
|
129
129
|
|
|
130
130
|
run()
|
|
131
131
|
|
|
132
|
-
from __ql_notify__ import send
|
|
133
|
-
|
|
134
132
|
class BaseApi(Client):
|
|
135
133
|
def notify(self, *args, **kwargs):
|
|
134
|
+
# Most scripts never send a notification. Python caches this
|
|
135
|
+
# module after the first call, including its channel dependencies.
|
|
136
|
+
from __ql_notify__ import send
|
|
137
|
+
|
|
136
138
|
return send(*args, **kwargs)
|
|
137
139
|
|
|
138
140
|
QLAPI = BaseApi()
|
package/shell/share.sh
CHANGED
|
@@ -110,7 +110,7 @@ t() {
|
|
|
110
110
|
fi
|
|
111
111
|
[[ -z $msg ]] && msg="$key"
|
|
112
112
|
# shellcheck disable=SC2059
|
|
113
|
-
printf "$msg\n" "$@"
|
|
113
|
+
printf -- "$msg\n" "$@"
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
set_proxy() {
|
|
@@ -305,8 +305,13 @@ reload_pm2() {
|
|
|
305
305
|
# Kill any existing node processes for qinglong
|
|
306
306
|
pkill -f "node.*static/build/app.js" 2>/dev/null || true
|
|
307
307
|
|
|
308
|
-
# Start node directly in the background
|
|
309
|
-
|
|
308
|
+
# Start node directly in the background. In containers, keep application
|
|
309
|
+
# output on the container streams instead of duplicating Winston logs on disk.
|
|
310
|
+
if [[ "$QL_CONTAINER" == "true" ]]; then
|
|
311
|
+
nohup node static/build/app.js >/proc/1/fd/1 2>/proc/1/fd/2 &
|
|
312
|
+
else
|
|
313
|
+
nohup node static/build/app.js >$dir_log/qinglong.log 2>&1 &
|
|
314
|
+
fi
|
|
310
315
|
local node_pid=$!
|
|
311
316
|
|
|
312
317
|
t '已使用 Node.js 直接启动服务 (PID: %s)' "$node_pid"
|
|
@@ -363,9 +368,16 @@ format_timestamp() {
|
|
|
363
368
|
|
|
364
369
|
get_env_array() {
|
|
365
370
|
exported_variables=()
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
371
|
+
# Preserve the legacy export-line/second-field rules without evaluating values.
|
|
372
|
+
local export_name_program='/^export / { name = $2; sub(/=.*/, "", name); print name }'
|
|
373
|
+
if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
|
|
374
|
+
builtin mapfile -t exported_variables < <(awk "$export_name_program" "$file_env")
|
|
375
|
+
else
|
|
376
|
+
# macOS still ships Bash 3, which does not provide mapfile.
|
|
377
|
+
while IFS= read -r line; do
|
|
378
|
+
exported_variables+=("$line")
|
|
379
|
+
done < <(awk "$export_name_program" "$file_env")
|
|
380
|
+
fi
|
|
369
381
|
}
|
|
370
382
|
|
|
371
383
|
clear_env() {
|
|
@@ -406,15 +418,20 @@ run_task_after() {
|
|
|
406
418
|
}
|
|
407
419
|
|
|
408
420
|
handle_task_end() {
|
|
409
|
-
local etime
|
|
410
|
-
|
|
411
|
-
|
|
421
|
+
local etime end_time end_timestamp
|
|
422
|
+
if [[ $is_macos -ne 1 && $time_format == '%Y-%m-%d %H:%M:%S' ]]; then
|
|
423
|
+
IFS='|' read -r end_time end_timestamp < <(date "+$time_format|%s")
|
|
424
|
+
else
|
|
425
|
+
etime=$(date "+$time_format")
|
|
426
|
+
end_time=$(format_time "$time_format" "$etime")
|
|
427
|
+
end_timestamp=$(format_timestamp "$time_format" "$etime")
|
|
428
|
+
fi
|
|
412
429
|
local diff_time=$(($end_timestamp - $begin_timestamp))
|
|
413
430
|
local exit_code="${_task_exit_code:-0}"
|
|
414
431
|
[[ "$diff_time" == 0 ]] && diff_time=1
|
|
415
432
|
|
|
416
433
|
if [[ $ID ]]; then
|
|
417
|
-
local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time")
|
|
434
|
+
local error=$(update_cron "\"$ID\"" "1" "$$" "$log_path" "$begin_timestamp" "$diff_time" "$exit_code")
|
|
418
435
|
if [[ $error ]]; then
|
|
419
436
|
error_message=", 状态更新失败(${error})"
|
|
420
437
|
fi
|
package/shell/start.sh
CHANGED
|
@@ -74,7 +74,7 @@ if [[ $command != "reload" ]]; then
|
|
|
74
74
|
;;
|
|
75
75
|
esac
|
|
76
76
|
|
|
77
|
-
npm install -g pnpm@8.3.1 pm2 ts-node
|
|
77
|
+
npm install -g pnpm@8.3.1 pm2 ts-node typescript@5
|
|
78
78
|
fi
|
|
79
79
|
|
|
80
80
|
export PYTHON_SHORT_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
|
|
@@ -91,8 +91,11 @@ if [[ $command != "reload" ]]; then
|
|
|
91
91
|
pip3 install --prefix ${PYTHON_HOME} requests
|
|
92
92
|
fi
|
|
93
93
|
|
|
94
|
-
cd ${QL_DIR}
|
|
95
|
-
|
|
94
|
+
cd "${QL_DIR}"
|
|
95
|
+
if [[ ! -e .env ]]; then
|
|
96
|
+
# Preserve user configuration, including a file created concurrently.
|
|
97
|
+
(umask 077; set -C; cat .env.example > .env)
|
|
98
|
+
fi
|
|
96
99
|
chmod 777 ${QL_DIR}/shell/*.sh
|
|
97
100
|
|
|
98
101
|
. ${QL_DIR}/shell/share.sh
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Fork from the current Bash state: an external `bash -c` would lose private
|
|
4
|
+
# before-hook variables, arrays and functions used by sourced Shell scripts.
|
|
5
|
+
run_task_command() {
|
|
6
|
+
local timeout_seconds
|
|
7
|
+
if [[ -z ${command_timeout_time:-} ]]; then
|
|
8
|
+
"$@"
|
|
9
|
+
return $?
|
|
10
|
+
fi
|
|
11
|
+
timeout_seconds=$(awk -v value="$command_timeout_time" 'BEGIN {
|
|
12
|
+
if (value !~ /^([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[smhd]?$/) exit 1
|
|
13
|
+
unit = substr(value, length(value), 1)
|
|
14
|
+
factor = unit == "d" ? 86400 : unit == "h" ? 3600 : unit == "m" ? 60 : 1
|
|
15
|
+
printf "%.9f", (value + 0) * factor
|
|
16
|
+
}') || { printf 'Invalid task timeout: %s\n' "$command_timeout_time" >&2; return 125; }
|
|
17
|
+
if [[ $timeout_seconds == '0.000000000' ]]; then
|
|
18
|
+
"$@"
|
|
19
|
+
return $?
|
|
20
|
+
fi
|
|
21
|
+
(
|
|
22
|
+
timeout_dir=$(mktemp -d "${TMPDIR:-/tmp}/ql-task-timeout.XXXXXXXX") || exit 125
|
|
23
|
+
# Both children get private process groups. The timer and the wrapper must
|
|
24
|
+
# survive terminating the task, and descendants must not outlive a timeout.
|
|
25
|
+
set -m
|
|
26
|
+
( set +m; "$@" ) <&0 &
|
|
27
|
+
timeout_worker=$!
|
|
28
|
+
(
|
|
29
|
+
set +m
|
|
30
|
+
: > "$timeout_dir/ready"
|
|
31
|
+
sleep "$timeout_seconds" || exit 125
|
|
32
|
+
: > "$timeout_dir/expired"
|
|
33
|
+
kill -TERM -- "-$timeout_worker" 2>/dev/null || :
|
|
34
|
+
sleep 0.5
|
|
35
|
+
kill -KILL -- "-$timeout_worker" 2>/dev/null || :
|
|
36
|
+
) &
|
|
37
|
+
timeout_watcher=$!
|
|
38
|
+
set +m
|
|
39
|
+
trap 'kill -KILL -- "-$timeout_watcher" 2>/dev/null || :
|
|
40
|
+
if kill -TERM -- "-$timeout_worker" 2>/dev/null; then sleep 0.1; fi
|
|
41
|
+
kill -KILL -- "-$timeout_worker" 2>/dev/null || :
|
|
42
|
+
wait "$timeout_worker" 2>/dev/null || :
|
|
43
|
+
wait "$timeout_watcher" 2>/dev/null || :
|
|
44
|
+
rm -rf -- "$timeout_dir"' EXIT
|
|
45
|
+
trap 'exit 130' INT
|
|
46
|
+
trap 'exit 143' TERM
|
|
47
|
+
trap 'exit 129' HUP
|
|
48
|
+
trap 'exit 131' QUIT
|
|
49
|
+
# Do not clean up a timer whose process group has not initialized yet.
|
|
50
|
+
while [[ ! -f "$timeout_dir/ready" ]]; do
|
|
51
|
+
kill -0 "$timeout_watcher" 2>/dev/null || exit 125
|
|
52
|
+
sleep 0.001
|
|
53
|
+
done
|
|
54
|
+
wait "$timeout_worker"
|
|
55
|
+
timeout_code=$?
|
|
56
|
+
if [[ -f "$timeout_dir/expired" ]]; then
|
|
57
|
+
# Let the timer finish escalation even if the task leader exited first.
|
|
58
|
+
wait "$timeout_watcher" 2>/dev/null || :
|
|
59
|
+
exit 124
|
|
60
|
+
fi
|
|
61
|
+
exit "$timeout_code"
|
|
62
|
+
)
|
|
63
|
+
}
|
package/shell/task.sh
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
dir_shell=$QL_DIR/shell
|
|
4
4
|
. $dir_shell/share.sh
|
|
5
5
|
. $dir_shell/api.sh
|
|
6
|
+
. $dir_shell/task-timeout.sh
|
|
6
7
|
|
|
7
8
|
trap 'single_hanle SIGINT' INT
|
|
8
9
|
trap 'single_hanle SIGTERM' TERM
|
|
@@ -18,6 +19,12 @@ single_hanle() {
|
|
|
18
19
|
exit 1
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
run_shell_script() {
|
|
23
|
+
# Preserve inherited variables/functions, but contain exit, exec and shell
|
|
24
|
+
# options so the task wrapper can run after hooks and report completion.
|
|
25
|
+
( . "$@" )
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
define_program() {
|
|
22
29
|
local file_param=$1
|
|
23
30
|
if [[ $file_param == *.js ]] || [[ $file_param == *.mjs ]]; then
|
|
@@ -25,7 +32,7 @@ define_program() {
|
|
|
25
32
|
elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
|
|
26
33
|
which_program="python3"
|
|
27
34
|
elif [[ $file_param == *.sh ]]; then
|
|
28
|
-
which_program="
|
|
35
|
+
which_program="run_shell_script"
|
|
29
36
|
elif [[ $file_param == *.ts ]]; then
|
|
30
37
|
which_program="ts-node-transpile-only"
|
|
31
38
|
else
|
|
@@ -52,8 +59,14 @@ handle_log_path() {
|
|
|
52
59
|
fi
|
|
53
60
|
fi
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
if [[ $is_macos -ne 1 && $mtime_format == '%Y-%m-%d %H:%M:%S.%3N' ]]; then
|
|
63
|
+
# Render both representations from one clock snapshot, without parsing it
|
|
64
|
+
# again in a second date process.
|
|
65
|
+
IFS='|' read -r time log_time < <(date "+$mtime_format|%Y-%m-%d-%H-%M-%S-%3N")
|
|
66
|
+
else
|
|
67
|
+
time=$(date "+$mtime_format")
|
|
68
|
+
log_time=$(format_log_time "$mtime_format" "$time")
|
|
69
|
+
fi
|
|
57
70
|
if [[ -z $log_name ]]; then
|
|
58
71
|
log_dir_tmp="${file_param##*/}"
|
|
59
72
|
if [[ $file_param =~ "/" ]]; then
|
|
@@ -100,11 +113,6 @@ format_params() {
|
|
|
100
113
|
mtime_format="%Y-%m-%d %H:%M:%S.%3N"
|
|
101
114
|
fi
|
|
102
115
|
timeoutCmd=""
|
|
103
|
-
if [[ $command_timeout_time ]]; then
|
|
104
|
-
if type timeout &>/dev/null; then
|
|
105
|
-
timeoutCmd="timeout --foreground -s 2 -k 10s $command_timeout_time "
|
|
106
|
-
fi
|
|
107
|
-
fi
|
|
108
116
|
# params=$(echo "$@" | sed -E 's/([^ ])&([^ ])/\1\\\&\2/g')
|
|
109
117
|
|
|
110
118
|
# 分割 task 内置参数和脚本参数
|
|
@@ -124,7 +132,11 @@ format_params() {
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
init_begin_time() {
|
|
127
|
-
|
|
135
|
+
if [[ $is_macos -ne 1 && $mtime_format == '%Y-%m-%d %H:%M:%S.%3N' && $time_format == '%Y-%m-%d %H:%M:%S' ]]; then
|
|
136
|
+
begin_time=${time%.*}
|
|
137
|
+
else
|
|
138
|
+
begin_time=$(format_time "$time_format" "$time")
|
|
139
|
+
fi
|
|
128
140
|
begin_timestamp=$(format_timestamp "$time_format" "$time")
|
|
129
141
|
}
|
|
130
142
|
|
package/shell/update.sh
CHANGED
|
@@ -211,6 +211,60 @@ run_extra_shell() {
|
|
|
211
211
|
fi
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
## 查看青龙服务日志
|
|
215
|
+
show_service_logs() {
|
|
216
|
+
local lines="15"
|
|
217
|
+
local no_stream="false"
|
|
218
|
+
while [[ $# -gt 0 ]]; do
|
|
219
|
+
case "$1" in
|
|
220
|
+
--lines)
|
|
221
|
+
if [[ ! "${2:-}" =~ ^[0-9]+$ ]]; then
|
|
222
|
+
echo "ql log: --lines requires a non-negative integer" >&2
|
|
223
|
+
return 2
|
|
224
|
+
fi
|
|
225
|
+
lines="$2"
|
|
226
|
+
shift 2
|
|
227
|
+
;;
|
|
228
|
+
--lines=*)
|
|
229
|
+
lines="${1#--lines=}"
|
|
230
|
+
if [[ ! "$lines" =~ ^[0-9]+$ ]]; then
|
|
231
|
+
echo "ql log: --lines requires a non-negative integer" >&2
|
|
232
|
+
return 2
|
|
233
|
+
fi
|
|
234
|
+
shift
|
|
235
|
+
;;
|
|
236
|
+
--nostream)
|
|
237
|
+
no_stream="true"
|
|
238
|
+
shift
|
|
239
|
+
;;
|
|
240
|
+
*)
|
|
241
|
+
echo "ql log: unknown option: $1" >&2
|
|
242
|
+
return 2
|
|
243
|
+
;;
|
|
244
|
+
esac
|
|
245
|
+
done
|
|
246
|
+
|
|
247
|
+
local system_log_dir="$dir_data/syslog"
|
|
248
|
+
local latest_system_log
|
|
249
|
+
latest_system_log=$(ls -1t "$system_log_dir"/*.log* 2>/dev/null | head -n 1)
|
|
250
|
+
if [[ "$lines" != "0" ]] && [[ -f "$latest_system_log" ]]; then
|
|
251
|
+
tail -n "$lines" "$latest_system_log"
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
if [[ "$no_stream" == "true" ]]; then
|
|
255
|
+
if [[ -z "$latest_system_log" ]]; then
|
|
256
|
+
echo "ql log: no system log found in $system_log_dir" >&2
|
|
257
|
+
return 1
|
|
258
|
+
fi
|
|
259
|
+
return 0
|
|
260
|
+
fi
|
|
261
|
+
|
|
262
|
+
# Winston writes the active runtime log by date. Follow the filename so
|
|
263
|
+
# size-based rotations are handled without involving the PM2 log files.
|
|
264
|
+
local current_system_log="$system_log_dir/$(date +%F).log"
|
|
265
|
+
tail -n 0 --retry -F "$current_system_log"
|
|
266
|
+
}
|
|
267
|
+
|
|
214
268
|
## 脚本用法
|
|
215
269
|
usage() {
|
|
216
270
|
t "$cmd_update 命令使用方法:"
|
|
@@ -221,105 +275,52 @@ usage() {
|
|
|
221
275
|
echo -e "5. $cmd_update rmlog <days> # 删除旧日志"
|
|
222
276
|
echo -e "6. $cmd_update bot # 启动tg-bot"
|
|
223
277
|
echo -e "7. $cmd_update check # 检测青龙环境并修复"
|
|
224
|
-
echo -e "8. $cmd_update
|
|
225
|
-
echo -e "9. $cmd_update
|
|
226
|
-
echo -e "10. $cmd_update
|
|
227
|
-
echo -e "11. $cmd_update
|
|
278
|
+
echo -e "8. $cmd_update log [--lines <n>] [--nostream] # 查看青龙运行日志"
|
|
279
|
+
echo -e "9. $cmd_update resetlet # 重置登录错误次数"
|
|
280
|
+
echo -e "10. $cmd_update resettfa # 禁用两步登录"
|
|
281
|
+
echo -e "11. $cmd_update resetpwd # 修改登录密码"
|
|
282
|
+
echo -e "12. $cmd_update resetname # 修改登录用户名"
|
|
228
283
|
}
|
|
229
284
|
|
|
230
285
|
reload_qinglong() {
|
|
231
|
-
echo -e "[reload_qinglong] deleting Triggered at $(date)" >>${dir_log}/reload.log
|
|
232
|
-
sleep 3
|
|
233
|
-
delete_pm2
|
|
234
|
-
echo -e "[reload_qinglong] deleted Triggered at $(date)" >>${dir_log}/reload.log
|
|
235
|
-
|
|
236
286
|
local reload_target="${1}"
|
|
237
|
-
local primary_branch="master"
|
|
238
|
-
if [[ "${QL_BRANCH}" == "develop" ]] || [[ "${QL_BRANCH}" == "debian" ]] || [[ "${QL_BRANCH}" == "debian-dev" ]]; then
|
|
239
|
-
primary_branch="${QL_BRANCH}"
|
|
240
|
-
fi
|
|
241
|
-
|
|
242
287
|
if [[ "$reload_target" == 'system' ]]; then
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
rm -rf $dir_static/*
|
|
246
|
-
mv -f ${dir_tmp}/qinglong-static-${primary_branch}/* ${dir_static}/
|
|
247
|
-
cp -f $file_config_sample $dir_config/config.sample.sh
|
|
288
|
+
QlPort="${ql_port:-${QlPort:-5700}}" QlBaseUrl="${ql_base_url:-${QlBaseUrl:-/}}" node "$dir_shell/upgrade.cjs" reload
|
|
289
|
+
return $?
|
|
248
290
|
fi
|
|
249
291
|
|
|
292
|
+
# Data import and a plain service restart retain their existing behavior.
|
|
293
|
+
echo -e "[reload_qinglong] deleting Triggered at $(date)" >>"${dir_log}/reload.log"
|
|
294
|
+
sleep 3
|
|
295
|
+
delete_pm2
|
|
250
296
|
if [[ "$reload_target" == 'data' ]]; then
|
|
251
|
-
rm -rf ${dir_data}/*
|
|
252
|
-
mv -f $
|
|
297
|
+
rm -rf "${dir_data:?}"/*
|
|
298
|
+
mv -f "$dir_tmp"/data/* "$dir_data"/ || return $?
|
|
253
299
|
fi
|
|
254
|
-
echo -e "[reload_qinglong] starting Triggered at $(date)" >>${dir_log}/reload.log
|
|
255
300
|
reload_pm2
|
|
256
|
-
echo -e "[reload_qinglong] started Triggered at $(date)\n" >>${dir_log}/reload.log
|
|
257
301
|
}
|
|
258
302
|
|
|
259
303
|
## 更新 qinglong
|
|
260
304
|
update_qinglong() {
|
|
261
|
-
rm -rf ${dir_tmp}/*
|
|
262
305
|
local mirror="gitee"
|
|
263
|
-
|
|
264
|
-
local downloadStaticUrl="https://gitee.com/whyour/qinglong-static/repository/archive"
|
|
265
|
-
local githubStatus=$(curl -s --noproxy "*" -m 2 -IL "https://google.com" | grep 200)
|
|
266
|
-
if [[ ! -z $githubStatus ]]; then
|
|
306
|
+
if curl --fail --silent --noproxy "*" --max-time 2 --head "https://github.com" >/dev/null; then
|
|
267
307
|
mirror="github"
|
|
268
|
-
downloadQLUrl="https://github.com/whyour/qinglong/archive/refs/heads"
|
|
269
|
-
downloadStaticUrl="https://github.com/whyour/qinglong-static/archive/refs/heads"
|
|
270
|
-
fi
|
|
271
|
-
t '使用 %s 源更新...\n' "${mirror}"
|
|
272
|
-
|
|
273
|
-
local primary_branch="master"
|
|
274
|
-
if [[ "${QL_BRANCH}" == "develop" ]] || [[ "${QL_BRANCH}" == "debian" ]] || [[ "${QL_BRANCH}" == "debian-dev" ]]; then
|
|
275
|
-
primary_branch="${QL_BRANCH}"
|
|
276
|
-
fi
|
|
277
|
-
|
|
278
|
-
wget -cqO "${dir_tmp}/ql.zip" "${downloadQLUrl}/${primary_branch}.zip"
|
|
279
|
-
exit_status=$?
|
|
280
|
-
|
|
281
|
-
if [[ $exit_status -eq 0 ]]; then
|
|
282
|
-
t '更新青龙源文件成功...\n'
|
|
283
|
-
|
|
284
|
-
unzip -oq ${dir_tmp}/ql.zip -d ${dir_tmp}
|
|
285
|
-
|
|
286
|
-
update_qinglong_static
|
|
287
|
-
else
|
|
288
|
-
t '更新青龙源文件失败,请检查网络...\n'
|
|
289
308
|
fi
|
|
309
|
+
t '使用 %s 源更新...\n' "$mirror"
|
|
310
|
+
QlPort="${ql_port:-${QlPort:-5700}}" QlBaseUrl="${ql_base_url:-${QlBaseUrl:-/}}" node "$dir_shell/upgrade.cjs" update "$mirror" "$needRestart"
|
|
290
311
|
}
|
|
291
312
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
check_update_dep
|
|
313
|
+
# Preserve the updater's status through both tee and the final timing output.
|
|
314
|
+
run_update_logged() (
|
|
315
|
+
set -o pipefail
|
|
316
|
+
if [[ "$real_time" == 'true' ]]; then
|
|
317
|
+
"$@"
|
|
318
|
+
elif [[ "$no_tee" == 'true' ]]; then
|
|
319
|
+
"$@" >>"$file_path" 2>&1
|
|
301
320
|
else
|
|
302
|
-
|
|
321
|
+
"$@" 2>&1 | tee -a "$file_path"
|
|
303
322
|
fi
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
check_update_dep() {
|
|
307
|
-
t '\n开始检测依赖...\n'
|
|
308
|
-
if [[ $(diff $dir_root/package.json ${dir_tmp}/qinglong-${primary_branch}/package.json) ]]; then
|
|
309
|
-
npm_install_2 "${dir_tmp}/qinglong-${primary_branch}"
|
|
310
|
-
fi
|
|
311
|
-
|
|
312
|
-
if [[ $exit_status -eq 0 ]]; then
|
|
313
|
-
t '\n依赖检测安装成功...\n'
|
|
314
|
-
t '更新包下载成功...\n'
|
|
315
|
-
|
|
316
|
-
if [[ "$needRestart" == 'true' ]]; then
|
|
317
|
-
reload_qinglong "system"
|
|
318
|
-
fi
|
|
319
|
-
else
|
|
320
|
-
t '\n依赖检测安装失败,请检查网络...\n'
|
|
321
|
-
fi
|
|
322
|
-
}
|
|
323
|
+
)
|
|
323
324
|
|
|
324
325
|
## 对比脚本
|
|
325
326
|
diff_scripts() {
|
|
@@ -374,23 +375,19 @@ gen_list_repo() {
|
|
|
374
375
|
|
|
375
376
|
cd ${repo_path}
|
|
376
377
|
|
|
377
|
-
local
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
local extension_string="${6:-$file_extensions}"
|
|
379
|
+
extension_string="${extension_string//|/ }"
|
|
380
|
+
extension_string="${extension_string//$'\n'/ }"
|
|
381
|
+
local -a extensions=() find_args=()
|
|
382
|
+
IFS=$' \t\n' read -r -a extensions <<< "$extension_string"
|
|
383
|
+
local extension
|
|
384
|
+
for extension in "${extensions[@]}"; do
|
|
385
|
+
if [[ ${#find_args[@]} -gt 0 ]]; then
|
|
386
|
+
find_args+=(-o)
|
|
383
387
|
fi
|
|
384
|
-
|
|
385
|
-
for extension in $file_extensions; do
|
|
386
|
-
if [[ $index -eq 0 ]]; then
|
|
387
|
-
cmd="${cmd} -name \"*.${extension}\""
|
|
388
|
-
else
|
|
389
|
-
cmd="${cmd} -o -name \"*.${extension}\""
|
|
390
|
-
fi
|
|
391
|
-
let index+=1
|
|
388
|
+
find_args+=(-name "*.${extension}")
|
|
392
389
|
done
|
|
393
|
-
files=$(
|
|
390
|
+
files=$(find . "${find_args[@]}" | sed 's/^..//')
|
|
394
391
|
if [[ $path ]]; then
|
|
395
392
|
files=$(echo "$files" | egrep "$path")
|
|
396
393
|
fi
|
|
@@ -403,7 +400,7 @@ gen_list_repo() {
|
|
|
403
400
|
|
|
404
401
|
if [[ $dependence ]]; then
|
|
405
402
|
cd ${repo_path}
|
|
406
|
-
results=$(
|
|
403
|
+
results=$(find . "${find_args[@]}" | sed 's/^..//' | egrep "$dependence")
|
|
407
404
|
for _file in ${results}; do
|
|
408
405
|
file_path=$(dirname $_file)
|
|
409
406
|
make_dir "${dir_scripts}/${uniq_path}/${file_path}"
|
|
@@ -471,6 +468,12 @@ main() {
|
|
|
471
468
|
local p8="${8}"
|
|
472
469
|
local p9="${9}"
|
|
473
470
|
local p10="${10}"
|
|
471
|
+
|
|
472
|
+
if [[ "$p1" == "log" ]]; then
|
|
473
|
+
show_service_logs "${@:2}"
|
|
474
|
+
return 0
|
|
475
|
+
fi
|
|
476
|
+
|
|
474
477
|
local log_dir="${p1}"
|
|
475
478
|
make_dir "$dir_log/$log_dir"
|
|
476
479
|
local log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
|
@@ -497,14 +500,17 @@ main() {
|
|
|
497
500
|
|
|
498
501
|
[[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp"
|
|
499
502
|
|
|
503
|
+
local command_status=0
|
|
500
504
|
case $p1 in
|
|
501
505
|
update)
|
|
502
506
|
fix_config
|
|
503
507
|
local needRestart=${p2:-"true"}
|
|
504
|
-
|
|
508
|
+
run_update_logged update_qinglong
|
|
509
|
+
command_status=$?
|
|
505
510
|
;;
|
|
506
511
|
reload)
|
|
507
|
-
|
|
512
|
+
run_update_logged reload_qinglong "$p2"
|
|
513
|
+
command_status=$?
|
|
508
514
|
;;
|
|
509
515
|
extra)
|
|
510
516
|
eval run_extra_shell $cmd
|
|
@@ -563,9 +569,9 @@ main() {
|
|
|
563
569
|
if [[ "$p1" != "repo" ]] && [[ "$p1" != "raw" ]]; then
|
|
564
570
|
eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒 " $cmd
|
|
565
571
|
fi
|
|
572
|
+
return "$command_status"
|
|
566
573
|
}
|
|
567
574
|
|
|
568
575
|
import_config "$@"
|
|
569
576
|
main "$@"
|
|
570
|
-
|
|
571
|
-
exit 0
|
|
577
|
+
exit $?
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The image updater and local CLI share one implementation and build contract.
|
|
2
|
+
const upgrade = require('../cli/src/internal/maintenance/upgradeArtifacts.cjs');
|
|
3
|
+
module.exports = upgrade;
|
|
4
|
+
if (require.main === module)
|
|
5
|
+
upgrade.main().catch((error) => {
|
|
6
|
+
console.error(`更新失败: ${error.message}`);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const express_1 = require("express");
|
|
4
|
+
const celebrate_1 = require("celebrate");
|
|
5
|
+
const trustProxy_1 = require("../shared/trustProxy");
|
|
6
|
+
const route = (0, express_1.Router)();
|
|
7
|
+
exports.default = (app) => {
|
|
8
|
+
app.use('/system/client-ip', route);
|
|
9
|
+
route.get('/config', async (req, res, next) => {
|
|
10
|
+
try {
|
|
11
|
+
res.send({ code: 200, data: await (0, trustProxy_1.getTrustProxyConfig)() });
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
next(error);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
route.put('/config', (0, celebrate_1.celebrate)({
|
|
18
|
+
body: celebrate_1.Joi.object({
|
|
19
|
+
trustProxy: celebrate_1.Joi.string().max(500).required(),
|
|
20
|
+
}),
|
|
21
|
+
}), async (req, res) => {
|
|
22
|
+
try {
|
|
23
|
+
const data = await (0, trustProxy_1.updateTrustProxy)(req.body.trustProxy);
|
|
24
|
+
res.send({ code: 200, data });
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
res.send({
|
|
28
|
+
code: 400,
|
|
29
|
+
message: error instanceof Error ? error.message : '配置更新失败',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
route.get('/diagnose', async (req, res, next) => {
|
|
34
|
+
try {
|
|
35
|
+
res.send({ code: 200, data: await (0, trustProxy_1.diagnoseClientIp)(req) });
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
next(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=clientIp.js.map
|
|
@@ -31,11 +31,11 @@ const typedi_1 = require("typedi");
|
|
|
31
31
|
const config_1 = __importDefault(require("../config"));
|
|
32
32
|
const fs = __importStar(require("fs/promises"));
|
|
33
33
|
const celebrate_1 = require("celebrate");
|
|
34
|
-
const path_1 = require("path");
|
|
35
34
|
const const_1 = require("../config/const");
|
|
36
35
|
const i18n_1 = require("../shared/i18n");
|
|
37
36
|
const config_2 = __importDefault(require("../services/config"));
|
|
38
37
|
const utils_1 = require("../shared/utils");
|
|
38
|
+
const fileAccess_1 = require("../shared/fileAccess");
|
|
39
39
|
const route = (0, express_1.Router)();
|
|
40
40
|
exports.default = (app) => {
|
|
41
41
|
app.use('/configs', route);
|
|
@@ -85,20 +85,11 @@ exports.default = (app) => {
|
|
|
85
85
|
const logger = typedi_1.Container.get('logger');
|
|
86
86
|
try {
|
|
87
87
|
const { name, content } = req.body;
|
|
88
|
-
// Resolve path first to prevent traversal attacks
|
|
89
|
-
let basePath = config_1.default.configPath;
|
|
90
88
|
if (name.startsWith('data/scripts/')) {
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
const cleanName = name.replace(/^data\/scripts\//, '');
|
|
94
|
-
const resolvedPath = (0, path_1.join)(basePath, cleanName);
|
|
95
|
-
const normalized = (0, path_1.join)(resolvedPath);
|
|
96
|
-
// Verify the resolved path stays within allowed directory
|
|
97
|
-
if (!normalized.startsWith(basePath)) {
|
|
98
|
-
return res.send({ code: 403, message: (0, i18n_1.t)('文件路径无效') });
|
|
89
|
+
return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
|
|
99
90
|
}
|
|
100
|
-
|
|
101
|
-
if (
|
|
91
|
+
const normalized = (0, fileAccess_1.resolveFileAccess)(config_1.default.configPath, [name], config_1.default.blackFileList);
|
|
92
|
+
if (!normalized) {
|
|
102
93
|
return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
|
|
103
94
|
}
|
|
104
95
|
await (0, utils_1.writeFileWithLock)(normalized, content);
|
|
@@ -108,14 +99,11 @@ exports.default = (app) => {
|
|
|
108
99
|
return next(e);
|
|
109
100
|
}
|
|
110
101
|
});
|
|
111
|
-
route.get('/:file',
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
return next(e);
|
|
118
|
-
}
|
|
102
|
+
route.get('/:file', (req, res) => {
|
|
103
|
+
return res.send({
|
|
104
|
+
code: 410,
|
|
105
|
+
message: (0, i18n_1.t)('接口已下线,请使用 /configs/detail 接口'),
|
|
106
|
+
});
|
|
119
107
|
});
|
|
120
108
|
};
|
|
121
109
|
//# sourceMappingURL=config.js.map
|