@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.
Files changed (362) hide show
  1. package/.dockerignore +13 -0
  2. package/.env.example +7 -0
  3. package/AGENTS.md +2 -2
  4. package/README-en.md +24 -0
  5. package/README.md +24 -0
  6. package/back/protos/api.proto +9 -1
  7. package/back/protos/cron.proto +8 -1
  8. package/deploy/kubernetes/README.md +81 -0
  9. package/deploy/kubernetes/base/kustomization.yaml +5 -0
  10. package/deploy/kubernetes/base/qinglong.yaml +95 -0
  11. package/deploy/kubernetes/overlays/example/kustomization.yaml +10 -0
  12. package/docker/Dockerfile +31 -12
  13. package/docker/Dockerfile.310 +31 -12
  14. package/docker/Dockerfile.debian +22 -14
  15. package/docker/Dockerfile.debian310 +24 -14
  16. package/docker/build-manifest.cjs +28 -0
  17. package/docker/verify-build.cjs +49 -0
  18. package/docs/development/node-cron-migration.md +49 -0
  19. package/docs/development/task-startup.md +78 -0
  20. package/docs/releases/2.22.0-validation.md +49 -0
  21. package/docs/releases/2.22.0.md +62 -0
  22. package/docs/releases/2.23.0.md +33 -0
  23. package/docs/script-history.md +53 -0
  24. package/ecosystem.config.js +10 -1
  25. package/package.json +19 -13
  26. package/sample/config.sample.sh +17 -2
  27. package/sample/notify.js +118 -0
  28. package/sample/notify.py +93 -0
  29. package/scripts/benchmark-execution.cjs +96 -0
  30. package/scripts/benchmark-script-history.cjs +39 -0
  31. package/scripts/publish-static.sh +34 -0
  32. package/scripts/sync-static.sh +20 -0
  33. package/scripts/wait-for-mirror.sh +214 -0
  34. package/scripts/write-build-info.cjs +27 -0
  35. package/shell/api.sh +96 -83
  36. package/shell/check.sh +59 -19
  37. package/shell/lang/en.sh +6 -0
  38. package/shell/lang/zh.sh +6 -0
  39. package/shell/node_path_cache.sh +136 -0
  40. package/shell/otask.sh +17 -10
  41. package/shell/preload/sitecustomize.js +11 -3
  42. package/shell/preload/sitecustomize.py +4 -2
  43. package/shell/share.sh +27 -10
  44. package/shell/start.sh +6 -3
  45. package/shell/task-timeout.sh +63 -0
  46. package/shell/task.sh +21 -9
  47. package/shell/update.sh +104 -98
  48. package/shell/upgrade.cjs +8 -0
  49. package/static/build/api/clientIp.js +42 -0
  50. package/static/build/api/config.js +9 -21
  51. package/static/build/api/cron.js +39 -3
  52. package/static/build/api/dashboard.js +50 -6
  53. package/static/build/api/env.js +17 -16
  54. package/static/build/api/health.js +2 -2
  55. package/static/build/api/index.js +4 -0
  56. package/static/build/api/log.js +39 -19
  57. package/static/build/api/open.js +2 -1
  58. package/static/build/api/retention.js +63 -0
  59. package/static/build/api/script.js +172 -25
  60. package/static/build/api/subscription.js +19 -8
  61. package/static/build/api/system.js +66 -12
  62. package/static/build/api/user.js +75 -15
  63. package/static/build/app.js +63 -54
  64. package/static/build/bootstrap/database.js +51 -0
  65. package/static/build/config/const.js +2 -0
  66. package/static/build/config/grpcCerts.js +93 -44
  67. package/static/build/config/index.js +0 -4
  68. package/static/build/config/share.js +5 -4
  69. package/static/build/config/subscription.js +19 -11
  70. package/static/build/config/util.js +142 -45
  71. package/static/build/data/cron.js +1 -0
  72. package/static/build/data/notify.js +18 -1
  73. package/static/build/data/sock.js +1 -0
  74. package/static/build/loaders/app.js +8 -6
  75. package/static/build/loaders/db.js +5 -35
  76. package/static/build/loaders/deps.js +30 -22
  77. package/static/build/loaders/express.js +46 -32
  78. package/static/build/loaders/initData.js +26 -33
  79. package/static/build/loaders/initFile.js +1 -1
  80. package/static/build/loaders/initTask.js +14 -3
  81. package/static/build/loaders/server.js +1 -1
  82. package/static/build/loaders/sock.js +72 -6
  83. package/static/build/middlewares/monitoring.js +12 -33
  84. package/static/build/middlewares/protectedPathCase.js +17 -0
  85. package/static/build/middlewares/uniqueConstraintError.js +15 -0
  86. package/static/build/protos/api.js +78 -2
  87. package/static/build/protos/cron.js +83 -5
  88. package/static/build/protos/health.js +1 -1
  89. package/static/build/schedule/addCron.js +67 -19
  90. package/static/build/schedule/api.js +5 -2
  91. package/static/build/schedule/client.js +56 -6
  92. package/static/build/schedule/delCron.js +11 -1
  93. package/static/build/schedule/health.js +72 -7
  94. package/static/build/schedule/setConcurrency.js +27 -0
  95. package/static/build/services/config.js +5 -43
  96. package/static/build/services/cron.js +389 -174
  97. package/static/build/services/dependence.js +66 -18
  98. package/static/build/services/env.js +1 -1
  99. package/static/build/services/grpc.js +4 -3
  100. package/static/build/services/health.js +4 -7
  101. package/static/build/services/http.js +9 -3
  102. package/static/build/services/log.js +2 -3
  103. package/static/build/services/metrics.js +46 -14
  104. package/static/build/services/notify.js +73 -5
  105. package/static/build/services/open.js +106 -31
  106. package/static/build/services/retention.js +123 -0
  107. package/static/build/services/schedule.js +77 -43
  108. package/static/build/services/script.js +4 -5
  109. package/static/build/services/scriptHistory.js +30 -0
  110. package/static/build/services/sshKey.js +39 -14
  111. package/static/build/services/subscription.js +161 -87
  112. package/static/build/services/system.js +116 -43
  113. package/static/build/services/user.js +255 -37
  114. package/static/build/shared/auth.js +22 -3
  115. package/static/build/shared/authMutation.js +17 -0
  116. package/static/build/shared/childProcess.js +82 -0
  117. package/static/build/shared/clientIp.js +27 -0
  118. package/static/build/shared/cronCommand.js +17 -0
  119. package/static/build/shared/cronSchedule.js +101 -0
  120. package/static/build/shared/cronScheduler.js +73 -0
  121. package/static/build/shared/errors.js +9 -0
  122. package/static/build/shared/fileAccess.js +60 -0
  123. package/static/build/shared/i18n.js +63 -4
  124. package/static/build/shared/logPath.js +15 -0
  125. package/static/build/shared/logReader.js +85 -0
  126. package/static/build/shared/logStreamManager.js +80 -60
  127. package/static/build/shared/loginThrottle.js +45 -0
  128. package/static/build/shared/pLimit.js +22 -8
  129. package/static/build/shared/password.js +30 -0
  130. package/static/build/shared/retention.js +58 -0
  131. package/static/build/shared/runCron.js +39 -17
  132. package/static/build/shared/schedulerMutationLock.js +44 -0
  133. package/static/build/shared/schedulerReadiness.js +82 -0
  134. package/static/build/shared/schemaMigrations.js +58 -0
  135. package/static/build/shared/scriptHistory.js +445 -0
  136. package/static/build/shared/shellQuote.js +11 -0
  137. package/static/build/shared/startupProcess.js +48 -0
  138. package/static/build/shared/store.js +7 -0
  139. package/static/build/shared/subscriptionMutationLock.js +34 -0
  140. package/static/build/shared/subscriptionPath.js +41 -0
  141. package/static/build/shared/subscriptionStorage.js +98 -0
  142. package/static/build/shared/trustProxy.js +119 -0
  143. package/static/build/shared/utils.js +2 -1
  144. package/static/build/token.js +3 -14
  145. package/static/build/validation/schedule.js +6 -12
  146. package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
  147. package/static/dist/2031.6af40025.async.js +1 -0
  148. package/static/dist/2693.51c2636b.async.js +1 -0
  149. package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
  150. package/static/dist/2901.2ca95295.async.js +1 -0
  151. package/static/dist/292.264757f0.async.js +1 -0
  152. package/static/dist/3512.95e41255.async.js +1 -0
  153. package/static/dist/445.a65ff63b.async.js +1 -0
  154. package/static/dist/4736.1d2b5cb6.async.js +1 -0
  155. package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
  156. package/static/dist/6212.9e6d9913.async.js +1 -0
  157. package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
  158. package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
  159. package/static/dist/7231.f7e5b668.async.js +1 -0
  160. package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
  161. package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
  162. package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
  163. package/static/dist/8844.a0fef08e.async.js +1 -0
  164. package/static/dist/index.html +2 -2
  165. package/static/dist/layouts__index.633d3553.async.js +1 -0
  166. package/static/dist/preload_helper.01fcd534.js +1 -0
  167. package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
  168. package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
  169. package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
  170. package/static/dist/{src__pages__crontab__logModal.0b8cce8c.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
  171. package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
  172. package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
  173. package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
  174. package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
  175. package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
  176. package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
  177. package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
  178. package/static/dist/src__pages__dependence__modal.0fa8b421.async.js +1 -0
  179. package/static/dist/src__pages__diff__index.b94e5dc5.async.js +1 -0
  180. package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
  181. package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
  182. package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
  183. package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
  184. package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
  185. package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
  186. package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
  187. package/static/dist/src__pages__script__editModal.afabf073.async.js +1 -0
  188. package/static/dist/src__pages__script__editNameModal.789ad87b.async.js +1 -0
  189. package/static/dist/src__pages__script__historyDrawer.8c58d958.async.js +1 -0
  190. package/static/dist/src__pages__script__historyDrawer.a449193a.chunk.css +1 -0
  191. package/static/dist/src__pages__script__index.ab360776.chunk.css +1 -0
  192. package/static/dist/src__pages__script__index.fc575945.async.js +1 -0
  193. package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
  194. package/static/dist/src__pages__script__saveModal.8fca1a22.async.js +1 -0
  195. package/static/dist/src__pages__script__saveWithHistory.99ece830.async.js +1 -0
  196. package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
  197. package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
  198. package/static/dist/src__pages__setting__checkUpdate.d175b154.async.js +1 -0
  199. package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
  200. package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
  201. package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
  202. package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
  203. package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
  204. package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
  205. package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
  206. package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
  207. package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
  208. package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
  209. package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
  210. package/static/dist/src__pages__subscription__modal.30868ba8.async.js +1 -0
  211. package/static/dist/{umi.ca04a019.js → umi.3a24a9fa.js} +1 -1
  212. package/test/back/advisory-input-security.test.cjs +416 -0
  213. package/test/back/auth-security.test.cjs +74 -0
  214. package/test/back/build-provenance.test.cjs +150 -0
  215. package/test/back/code-scanning-security.test.cjs +189 -0
  216. package/test/back/cron-log-name.test.cjs +110 -0
  217. package/test/back/cron-macros.test.cjs +51 -0
  218. package/test/back/cron-schedule-compatibility.test.cjs +69 -0
  219. package/test/back/cron-scheduler-routing.test.cjs +59 -0
  220. package/test/back/cron-validation.test.cjs +45 -0
  221. package/test/back/dashboard-failures.test.cjs +173 -0
  222. package/test/back/database-bootstrap.test.cjs +193 -0
  223. package/test/back/dependence-cache-status.test.cjs +125 -0
  224. package/test/back/deprecated-file-routes.test.cjs +82 -0
  225. package/test/back/draft-path-security.test.cjs +235 -0
  226. package/test/back/ecosystem.test.cjs +28 -0
  227. package/test/back/env-import-security.test.cjs +91 -0
  228. package/test/back/env-name-parsing.test.cjs +96 -0
  229. package/test/back/execution-lifecycle.test.cjs +236 -0
  230. package/test/back/file-access-scope.test.cjs +180 -0
  231. package/test/back/file-access-security.test.cjs +47 -0
  232. package/test/back/fileTreeListing.test.cjs +57 -0
  233. package/test/back/grpc-cron-response.test.cjs +60 -0
  234. package/test/back/grpc-mtls-security.test.cjs +136 -0
  235. package/test/back/http-exclusive-listen.test.cjs +31 -0
  236. package/test/back/http-security.test.cjs +313 -0
  237. package/test/back/legacy-cron-recovery.test.cjs +76 -0
  238. package/test/back/linux-mirror-result.test.cjs +176 -0
  239. package/test/back/listen-security.test.cjs +68 -0
  240. package/test/back/log-path-security.test.cjs +158 -0
  241. package/test/back/logReader.test.cjs +72 -0
  242. package/test/back/manual-execution.test.cjs +85 -0
  243. package/test/back/manual-stop-claim.test.cjs +220 -0
  244. package/test/back/metrics.test.cjs +34 -0
  245. package/test/back/mirror-status.test.cjs +257 -0
  246. package/test/back/monitoring.test.cjs +73 -0
  247. package/test/back/node-cron-migration.test.cjs +65 -0
  248. package/test/back/node-path-cache.test.cjs +202 -0
  249. package/test/back/node-path-lock.test.cjs +182 -0
  250. package/test/back/npm-publication.test.cjs +70 -0
  251. package/test/back/preload-lazy-notify.test.cjs +168 -0
  252. package/test/back/primary-apm.test.cjs +24 -0
  253. package/test/back/process-exit-state.test.cjs +81 -0
  254. package/test/back/process-stop-signal.test.cjs +77 -0
  255. package/test/back/protected-path-case.test.cjs +58 -0
  256. package/test/back/qlServiceLogCommand.test.cjs +128 -0
  257. package/test/back/queued-cron-invalidation.test.cjs +98 -0
  258. package/test/back/restart-instance-recovery.test.cjs +116 -0
  259. package/test/back/retention.test.cjs +131 -0
  260. package/test/back/role-loading.test.cjs +118 -0
  261. package/test/back/schedule-health.test.cjs +86 -0
  262. package/test/back/scheduler-bulk-recovery.test.cjs +40 -0
  263. package/test/back/scheduler-concurrency.test.cjs +411 -0
  264. package/test/back/scheduler-file-lock.test.cjs +51 -0
  265. package/test/back/scheduler-mutation.test.cjs +312 -0
  266. package/test/back/scheduler-readiness.test.cjs +85 -0
  267. package/test/back/scheduler-reconciliation.test.cjs +206 -0
  268. package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
  269. package/test/back/schema-migrations.test.cjs +127 -0
  270. package/test/back/script-file-access.test.cjs +210 -0
  271. package/test/back/script-history-api.test.cjs +551 -0
  272. package/test/back/script-history.test.cjs +383 -0
  273. package/test/back/shell-api-parsing.test.cjs +184 -0
  274. package/test/back/shell-translation-output.test.cjs +16 -0
  275. package/test/back/shell-upgrade.test.cjs +312 -0
  276. package/test/back/shellApiToken.test.cjs +151 -0
  277. package/test/back/sock-polling.test.cjs +297 -0
  278. package/test/back/sock-security.test.cjs +72 -0
  279. package/test/back/ssh-config-home.test.cjs +113 -0
  280. package/test/back/start-env-preservation.test.cjs +53 -0
  281. package/test/back/static-mirror-trigger.test.cjs +441 -0
  282. package/test/back/static-mirror.test.cjs +179 -0
  283. package/test/back/stop-failure-feedback.test.cjs +158 -0
  284. package/test/back/stop-race.test.cjs +171 -0
  285. package/test/back/subscription-cleanup.test.cjs +53 -0
  286. package/test/back/subscription-mutation-lock.test.cjs +83 -0
  287. package/test/back/subscription-review-regression.test.cjs +607 -0
  288. package/test/back/subscription-stop-state.test.cjs +66 -0
  289. package/test/back/subscription-storage-regression.test.cjs +553 -0
  290. package/test/back/system-dependence-cache.test.cjs +127 -0
  291. package/test/back/system-export-history.test.cjs +119 -0
  292. package/test/back/systemTokenRenewal.test.cjs +497 -0
  293. package/test/back/task-shell-lifecycle.test.cjs +194 -0
  294. package/test/back/task-time.test.cjs +116 -0
  295. package/test/back/unique-constraint-error.test.cjs +72 -0
  296. package/test/back/upgrade-guards.test.cjs +285 -0
  297. package/test/back/upgrade-lifecycle.test.cjs +288 -0
  298. package/test/back/upgrade-transaction.test.cjs +133 -0
  299. package/test/back/user-api.test.cjs +99 -0
  300. package/test/back/user-security.test.cjs +349 -0
  301. package/test/back/worker-apm.test.cjs +84 -0
  302. package/test/back/wpush-grpc.test.cjs +116 -0
  303. package/test/fixtures/legacy-cron.json +1371 -0
  304. package/test/front/cron-log-pagination.test.cjs +214 -0
  305. package/test/front/diff-file-routing.test.cjs +126 -0
  306. package/test/front/http-auth.test.cjs +152 -0
  307. package/test/front/http-error.test.cjs +29 -0
  308. package/test/front/script-history-save.test.cjs +121 -0
  309. package/test/helpers/load-security-module.cjs +42 -0
  310. package/test/helpers/upgrade-fixture.cjs +30 -0
  311. package/version.yaml +14 -34
  312. package/CLAUDE.md +0 -43
  313. package/static/dist/1147.c420132e.async.js +0 -1
  314. package/static/dist/134.54df9e38.async.js +0 -1
  315. package/static/dist/2096.6d98fd12.async.js +0 -1
  316. package/static/dist/2208.f7ba3dfa.async.js +0 -1
  317. package/static/dist/2286.164bb089.async.js +0 -1
  318. package/static/dist/3191.63263871.async.js +0 -1
  319. package/static/dist/4859.6592cebb.async.js +0 -1
  320. package/static/dist/4902.555f92ab.async.js +0 -1
  321. package/static/dist/5520.ff2cfd6b.async.js +0 -1
  322. package/static/dist/6431.c50479be.async.js +0 -1
  323. package/static/dist/6707.801b886b.async.js +0 -1
  324. package/static/dist/8826.2447a104.async.js +0 -1
  325. package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
  326. package/static/dist/preload_helper.0431c0f3.js +0 -1
  327. package/static/dist/src__pages__crontab__detail.b9c36808.async.js +0 -1
  328. package/static/dist/src__pages__crontab__index.fed99fd0.async.js +0 -1
  329. package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
  330. package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
  331. package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
  332. package/static/dist/src__pages__dashboard__index.b30f2f47.async.js +0 -1
  333. package/static/dist/src__pages__dependence__index.3d87ceac.async.js +0 -1
  334. package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
  335. package/static/dist/src__pages__dependence__modal.11124896.async.js +0 -1
  336. package/static/dist/src__pages__diff__index.013b7c75.async.js +0 -1
  337. package/static/dist/src__pages__env__editNameModal.5d264b25.async.js +0 -1
  338. package/static/dist/src__pages__env__index.baa27d4e.async.js +0 -1
  339. package/static/dist/src__pages__env__modal.7f2ef1bc.async.js +0 -1
  340. package/static/dist/src__pages__error__index.f156b45e.async.js +0 -1
  341. package/static/dist/src__pages__initialization__index.e96d4ba8.async.js +0 -1
  342. package/static/dist/src__pages__log__index.e0978bae.async.js +0 -1
  343. package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
  344. package/static/dist/src__pages__script__editNameModal.3e7e100d.async.js +0 -1
  345. package/static/dist/src__pages__script__index.2765d1b8.async.js +0 -1
  346. package/static/dist/src__pages__script__index.60b6f827.chunk.css +0 -1
  347. package/static/dist/src__pages__script__renameModal.5e987ef5.async.js +0 -1
  348. package/static/dist/src__pages__script__saveModal.3f9d23d6.async.js +0 -1
  349. package/static/dist/src__pages__script__setting.a535793a.async.js +0 -1
  350. package/static/dist/src__pages__setting__appModal.251cd14f.async.js +0 -1
  351. package/static/dist/src__pages__setting__checkUpdate.46efe057.async.js +0 -1
  352. package/static/dist/src__pages__setting__dependence.8a7a9529.async.js +0 -1
  353. package/static/dist/src__pages__setting__index.cc85fdfb.async.js +0 -1
  354. package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
  355. package/static/dist/src__pages__setting__notification.390fc905.async.js +0 -1
  356. package/static/dist/src__pages__setting__other.b22d2165.async.js +0 -1
  357. package/static/dist/src__pages__setting__security.598720a8.async.js +0 -1
  358. package/static/dist/src__pages__setting__systemLog.67406721.async.js +0 -1
  359. package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
  360. package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
  361. package/static/dist/src__pages__subscription__modal.3562c670.async.js +0 -1
  362. /package/static/dist/{4859.1b962b29.chunk.css → 292.1b962b29.chunk.css} +0 -0
@@ -2,10 +2,10 @@
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
4
  // protoc-gen-ts_proto v2.6.1
5
- // protoc v3.21.12
5
+ // protoc v5.28.3
6
6
  // source: back/protos/cron.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.CronClient = exports.CronService = exports.DeleteCronResponse = exports.DeleteCronRequest = exports.AddCronResponse = exports.AddCronRequest = exports.ICron = exports.ISchedule = exports.protobufPackage = void 0;
8
+ exports.CronClient = exports.CronService = exports.SetConcurrencyRequest = exports.DeleteCronResponse = exports.DeleteCronRequest = exports.AddCronResponse = exports.AddCronRequest = exports.ICron = exports.ISchedule = exports.protobufPackage = void 0;
9
9
  /* eslint-disable */
10
10
  const wire_1 = require("@bufbuild/protobuf/wire");
11
11
  const grpc_js_1 = require("@grpc/grpc-js");
@@ -180,13 +180,16 @@ exports.ICron = {
180
180
  },
181
181
  };
182
182
  function createBaseAddCronRequest() {
183
- return { crons: [] };
183
+ return { crons: [], replace: false };
184
184
  }
185
185
  exports.AddCronRequest = {
186
186
  encode(message, writer = new wire_1.BinaryWriter()) {
187
187
  for (const v of message.crons) {
188
188
  exports.ICron.encode(v, writer.uint32(10).fork()).join();
189
189
  }
190
+ if (message.replace !== false) {
191
+ writer.uint32(16).bool(message.replace);
192
+ }
190
193
  return writer;
191
194
  },
192
195
  decode(input, length) {
@@ -203,6 +206,13 @@ exports.AddCronRequest = {
203
206
  message.crons.push(exports.ICron.decode(reader, reader.uint32()));
204
207
  continue;
205
208
  }
209
+ case 2: {
210
+ if (tag !== 16) {
211
+ break;
212
+ }
213
+ message.replace = reader.bool();
214
+ continue;
215
+ }
206
216
  }
207
217
  if ((tag & 7) === 4 || tag === 0) {
208
218
  break;
@@ -212,7 +222,10 @@ exports.AddCronRequest = {
212
222
  return message;
213
223
  },
214
224
  fromJSON(object) {
215
- return { crons: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.crons) ? object.crons.map((e) => exports.ICron.fromJSON(e)) : [] };
225
+ return {
226
+ crons: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.crons) ? object.crons.map((e) => exports.ICron.fromJSON(e)) : [],
227
+ replace: isSet(object.replace) ? globalThis.Boolean(object.replace) : false,
228
+ };
216
229
  },
217
230
  toJSON(message) {
218
231
  var _a;
@@ -220,15 +233,19 @@ exports.AddCronRequest = {
220
233
  if ((_a = message.crons) === null || _a === void 0 ? void 0 : _a.length) {
221
234
  obj.crons = message.crons.map((e) => exports.ICron.toJSON(e));
222
235
  }
236
+ if (message.replace !== false) {
237
+ obj.replace = message.replace;
238
+ }
223
239
  return obj;
224
240
  },
225
241
  create(base) {
226
242
  return exports.AddCronRequest.fromPartial(base !== null && base !== void 0 ? base : {});
227
243
  },
228
244
  fromPartial(object) {
229
- var _a;
245
+ var _a, _b;
230
246
  const message = createBaseAddCronRequest();
231
247
  message.crons = ((_a = object.crons) === null || _a === void 0 ? void 0 : _a.map((e) => exports.ICron.fromPartial(e))) || [];
248
+ message.replace = (_b = object.replace) !== null && _b !== void 0 ? _b : false;
232
249
  return message;
233
250
  },
234
251
  };
@@ -359,6 +376,58 @@ exports.DeleteCronResponse = {
359
376
  return message;
360
377
  },
361
378
  };
379
+ function createBaseSetConcurrencyRequest() {
380
+ return { concurrency: 0 };
381
+ }
382
+ exports.SetConcurrencyRequest = {
383
+ encode(message, writer = new wire_1.BinaryWriter()) {
384
+ if (message.concurrency !== 0) {
385
+ writer.uint32(8).int32(message.concurrency);
386
+ }
387
+ return writer;
388
+ },
389
+ decode(input, length) {
390
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
391
+ let end = length === undefined ? reader.len : reader.pos + length;
392
+ const message = createBaseSetConcurrencyRequest();
393
+ while (reader.pos < end) {
394
+ const tag = reader.uint32();
395
+ switch (tag >>> 3) {
396
+ case 1: {
397
+ if (tag !== 8) {
398
+ break;
399
+ }
400
+ message.concurrency = reader.int32();
401
+ continue;
402
+ }
403
+ }
404
+ if ((tag & 7) === 4 || tag === 0) {
405
+ break;
406
+ }
407
+ reader.skip(tag & 7);
408
+ }
409
+ return message;
410
+ },
411
+ fromJSON(object) {
412
+ return { concurrency: isSet(object.concurrency) ? globalThis.Number(object.concurrency) : 0 };
413
+ },
414
+ toJSON(message) {
415
+ const obj = {};
416
+ if (message.concurrency !== 0) {
417
+ obj.concurrency = Math.round(message.concurrency);
418
+ }
419
+ return obj;
420
+ },
421
+ create(base) {
422
+ return exports.SetConcurrencyRequest.fromPartial(base !== null && base !== void 0 ? base : {});
423
+ },
424
+ fromPartial(object) {
425
+ var _a;
426
+ const message = createBaseSetConcurrencyRequest();
427
+ message.concurrency = (_a = object.concurrency) !== null && _a !== void 0 ? _a : 0;
428
+ return message;
429
+ },
430
+ };
362
431
  exports.CronService = {
363
432
  addCron: {
364
433
  path: "/com.ql.cron.Cron/addCron",
@@ -378,6 +447,15 @@ exports.CronService = {
378
447
  responseSerialize: (value) => Buffer.from(exports.DeleteCronResponse.encode(value).finish()),
379
448
  responseDeserialize: (value) => exports.DeleteCronResponse.decode(value),
380
449
  },
450
+ setConcurrency: {
451
+ path: "/com.ql.cron.Cron/setConcurrency",
452
+ requestStream: false,
453
+ responseStream: false,
454
+ requestSerialize: (value) => Buffer.from(exports.SetConcurrencyRequest.encode(value).finish()),
455
+ requestDeserialize: (value) => exports.SetConcurrencyRequest.decode(value),
456
+ responseSerialize: (value) => Buffer.from(exports.AddCronResponse.encode(value).finish()),
457
+ responseDeserialize: (value) => exports.AddCronResponse.decode(value),
458
+ },
381
459
  };
382
460
  exports.CronClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.CronService, "com.ql.cron.Cron");
383
461
  function isSet(value) {
@@ -2,7 +2,7 @@
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
4
  // protoc-gen-ts_proto v2.6.1
5
- // protoc v3.21.12
5
+ // protoc v3.17.3
6
6
  // source: back/protos/health.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.HealthClient = exports.HealthService = exports.HealthCheckResponse = exports.HealthCheckRequest = exports.healthCheckResponse_ServingStatusToJSON = exports.healthCheckResponse_ServingStatusFromJSON = exports.HealthCheckResponse_ServingStatus = exports.protobufPackage = void 0;
@@ -4,35 +4,83 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addCron = void 0;
7
- const node_schedule_1 = __importDefault(require("node-schedule"));
7
+ const grpc_js_1 = require("@grpc/grpc-js");
8
+ const cronScheduler_1 = require("../shared/cronScheduler");
9
+ const cronSchedule_1 = require("../shared/cronSchedule");
8
10
  const data_1 = require("./data");
9
11
  const runCron_1 = require("../shared/runCron");
10
12
  const logger_1 = __importDefault(require("../loaders/logger"));
13
+ const i18n_1 = require("../shared/i18n");
14
+ // Validate the entire batch before replacing any existing jobs.
15
+ const isValidCronField = (cron) => {
16
+ return (0, cronSchedule_1.isValidCronSchedule)(cron);
17
+ };
11
18
  const addCron = (call, callback) => {
12
- var _a;
19
+ var _a, _b;
20
+ // ===== 第一遍:预校验所有 cron 表达式 =====
21
+ const validationErrors = [];
13
22
  for (const item of call.request.crons) {
14
- const { id, schedule, command, extra_schedules, name } = item;
15
- if (data_1.scheduleStacks.has(id)) {
16
- (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.forEach((x) => x.cancel());
23
+ const { id, schedule, extra_schedules } = item;
24
+ if (!isValidCronField(schedule)) {
25
+ validationErrors.push((0, i18n_1.tf)('任务ID %s: 无效的 cron 表达式 "%s"', String(id), schedule));
17
26
  }
18
- logger_1.default.info('[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, schedule, command);
19
27
  if (extra_schedules === null || extra_schedules === void 0 ? void 0 : extra_schedules.length) {
20
28
  extra_schedules.forEach((x) => {
21
- logger_1.default.info('[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, x.schedule, command);
29
+ if (!isValidCronField(x.schedule)) {
30
+ validationErrors.push((0, i18n_1.tf)('任务ID %s (extra_schedule): 无效的 cron 表达式 "%s"', String(id), x.schedule));
31
+ }
22
32
  });
23
33
  }
24
- data_1.scheduleStacks.set(id, [
25
- node_schedule_1.default.scheduleJob(id, schedule, async () => {
26
- logger_1.default.info(`[schedule][准备运行任务] 命令: ${command}`);
27
- (0, runCron_1.runCron)(command, item);
28
- }),
29
- ...((extra_schedules === null || extra_schedules === void 0 ? void 0 : extra_schedules.length)
30
- ? extra_schedules.map((x) => node_schedule_1.default.scheduleJob(id, x.schedule, async () => {
31
- logger_1.default.info(`[schedule][准备运行任务] 命令: ${command}`);
32
- (0, runCron_1.runCron)(command, item);
33
- }))
34
- : []),
35
- ]);
34
+ }
35
+ if (validationErrors.length > 0) {
36
+ const details = validationErrors.join('\n');
37
+ const err = new Error(details);
38
+ err.code = grpc_js_1.status.INVALID_ARGUMENT;
39
+ err.details = details;
40
+ callback(err, null);
41
+ return;
42
+ }
43
+ // Prepare stopped jobs first: construction errors must preserve the old snapshot.
44
+ const prepared = new Map();
45
+ try {
46
+ for (const item of call.request.crons) {
47
+ const jobs = [];
48
+ (_a = prepared.get(item.id)) === null || _a === void 0 ? void 0 : _a.forEach((job) => job.cancel());
49
+ prepared.set(item.id, jobs);
50
+ for (const schedule of [
51
+ item.schedule,
52
+ ...(item.extra_schedules || []).map((x) => x.schedule),
53
+ ]) {
54
+ jobs.push((0, cronScheduler_1.createCronJob)(schedule, async () => {
55
+ logger_1.default.info('[schedule][准备运行任务] 命令: %s', item.command);
56
+ await (0, runCron_1.runCron)(item.command, item, () => data_1.scheduleStacks.get(item.id) === jobs);
57
+ }, {
58
+ name: `${item.id}: ${item.name || ''}`,
59
+ logger: logger_1.default,
60
+ start: false,
61
+ }));
62
+ }
63
+ }
64
+ }
65
+ catch (error) {
66
+ for (const jobs of prepared.values())
67
+ jobs.forEach((job) => job.cancel());
68
+ const err = new Error(error instanceof Error ? error.message : String(error));
69
+ err.code = grpc_js_1.status.INVALID_ARGUMENT;
70
+ err.details = err.message;
71
+ callback(err, null);
72
+ return;
73
+ }
74
+ if (call.request.replace) {
75
+ for (const jobs of data_1.scheduleStacks.values())
76
+ jobs.forEach((job) => job === null || job === void 0 ? void 0 : job.cancel());
77
+ data_1.scheduleStacks.clear();
78
+ }
79
+ for (const [id, jobs] of prepared) {
80
+ (_b = data_1.scheduleStacks.get(id)) === null || _b === void 0 ? void 0 : _b.forEach((job) => job.cancel());
81
+ data_1.scheduleStacks.set(id, jobs);
82
+ jobs.forEach((job) => job.start());
83
+ logger_1.default.info('[schedule][创建定时任务] 任务ID: %s, 规则数: %s', id, jobs.length);
36
84
  }
37
85
  callback(null, null);
38
86
  };
@@ -22,6 +22,7 @@ const logger_1 = __importDefault(require("../loaders/logger"));
22
22
  const pick_1 = __importDefault(require("lodash/pick"));
23
23
  const system_1 = __importDefault(require("../services/system"));
24
24
  const cron_1 = __importDefault(require("../services/cron"));
25
+ const sequelize_1 = require("sequelize");
25
26
  typedi_1.Container.set('logger', logger_1.default);
26
27
  const getEnvs = async (call, callback) => {
27
28
  try {
@@ -200,10 +201,12 @@ const systemNotify = async (call, callback) => {
200
201
  };
201
202
  exports.systemNotify = systemNotify;
202
203
  const normalizeCronData = (data) => {
203
- var _a, _b, _c, _d, _e;
204
+ var _a, _b, _c, _d, _e, _f;
204
205
  if (!data)
205
206
  return undefined;
206
- return Object.assign(Object.assign({}, data), { sub_id: (_a = data.sub_id) !== null && _a !== void 0 ? _a : undefined, extra_schedules: (_b = data.extra_schedules) !== null && _b !== void 0 ? _b : [], pid: (_c = data.pid) !== null && _c !== void 0 ? _c : undefined, task_before: (_d = data.task_before) !== null && _d !== void 0 ? _d : undefined, task_after: (_e = data.task_after) !== null && _e !== void 0 ? _e : undefined });
207
+ // create() returns a Sequelize instance; spreading it omits attribute getters.
208
+ const cron = data instanceof sequelize_1.Model ? data.get({ plain: true }) : data;
209
+ return Object.assign(Object.assign({}, cron), { labels: (_a = cron.labels) !== null && _a !== void 0 ? _a : [], sub_id: (_b = cron.sub_id) !== null && _b !== void 0 ? _b : undefined, extra_schedules: (_c = cron.extra_schedules) !== null && _c !== void 0 ? _c : [], pid: (_d = cron.pid) !== null && _d !== void 0 ? _d : undefined, task_before: (_e = cron.task_before) !== null && _e !== void 0 ? _e : undefined, task_after: (_f = cron.task_after) !== null && _f !== void 0 ? _f : undefined });
207
210
  };
208
211
  const getCronDetail = async (call, callback) => {
209
212
  try {
@@ -7,10 +7,30 @@ const grpc_js_1 = require("@grpc/grpc-js");
7
7
  const cron_1 = require("../protos/cron");
8
8
  const config_1 = __importDefault(require("../config"));
9
9
  const grpcCerts_1 = require("../config/grpcCerts");
10
+ const health_1 = require("../protos/health");
11
+ const schedulerReadiness_1 = require("../shared/schedulerReadiness");
10
12
  class Client {
11
13
  constructor() {
14
+ this.readiness = new schedulerReadiness_1.SchedulerReadiness(() => this.probe());
12
15
  this._client = null;
13
16
  }
17
+ async waitForReady(timeoutMs) {
18
+ try {
19
+ await new Promise((resolve, reject) => {
20
+ this.client.waitForReady(Date.now() + timeoutMs, (err) => err ? reject(err) : resolve());
21
+ });
22
+ }
23
+ catch (error) {
24
+ this.readiness.invalidate();
25
+ throw Object.assign(error instanceof Error ? error : new Error(String(error)), { status: 503 });
26
+ }
27
+ }
28
+ async probe() {
29
+ await this.waitForReady(1000);
30
+ await new Promise((resolve, reject) => {
31
+ this.client.makeUnaryRequest(health_1.HealthService.check.path, health_1.HealthService.check.requestSerialize, health_1.HealthService.check.responseDeserialize, { service: 'scheduler' }, { deadline: Date.now() + 1000 }, (err, res) => err ? reject(err) : (res === null || res === void 0 ? void 0 : res.status) === 1 ? resolve() : reject(new Error('Scheduler unavailable')));
32
+ });
33
+ }
14
34
  get client() {
15
35
  if (!this._client) {
16
36
  const tlsConfig = (0, grpcCerts_1.getGrpcCerts)();
@@ -18,21 +38,51 @@ class Client {
18
38
  }
19
39
  return this._client;
20
40
  }
21
- addCron(request) {
41
+ async setConcurrency(concurrency) {
42
+ await this.waitForReady(2000);
43
+ return new Promise((resolve, reject) => {
44
+ this.client.setConcurrency({ concurrency }, new grpc_js_1.Metadata(), { deadline: Date.now() + 5000 }, (err) => {
45
+ if (err) {
46
+ if (err.code === grpc_js_1.status.UNAVAILABLE || err.code === grpc_js_1.status.DEADLINE_EXCEEDED) {
47
+ this.readiness.invalidate();
48
+ Object.assign(err, { status: 503 });
49
+ }
50
+ return reject(err);
51
+ }
52
+ resolve();
53
+ });
54
+ });
55
+ }
56
+ async addCron(request, replace = false) {
57
+ await this.waitForReady(2000);
58
+ // Include every rule in a recovery snapshot, but bound a stuck worker.
59
+ const ruleCount = request.reduce((count, item) => { var _a; return count + 1 + (((_a = item.extra_schedules) === null || _a === void 0 ? void 0 : _a.length) || 0); }, 0);
60
+ const registrationTimeoutMs = Math.min(120000, 5000 + ruleCount * 5);
22
61
  return new Promise((resolve, reject) => {
23
- this.client.addCron({ crons: request }, (err, res) => {
62
+ this.client.addCron({ crons: request, replace }, new grpc_js_1.Metadata(), { deadline: Date.now() + registrationTimeoutMs }, (err, res) => {
24
63
  if (err) {
25
- reject(err);
64
+ if (err.code === grpc_js_1.status.UNAVAILABLE || err.code === grpc_js_1.status.DEADLINE_EXCEEDED) {
65
+ // A timed-out write may already have reached the scheduler.
66
+ // Reconcile its state from the DB instead of replaying the RPC.
67
+ this.readiness.invalidate();
68
+ Object.assign(err, { status: 503 });
69
+ }
70
+ return reject(err);
26
71
  }
27
72
  resolve(res);
28
73
  });
29
74
  });
30
75
  }
31
- delCron(request) {
76
+ async delCron(request) {
77
+ await this.waitForReady(2000);
32
78
  return new Promise((resolve, reject) => {
33
- this.client.delCron({ ids: request }, (err, res) => {
79
+ this.client.delCron({ ids: request }, new grpc_js_1.Metadata(), { deadline: Date.now() + 5000 }, (err, res) => {
34
80
  if (err) {
35
- reject(err);
81
+ if (err.code === grpc_js_1.status.UNAVAILABLE || err.code === grpc_js_1.status.DEADLINE_EXCEEDED) {
82
+ this.readiness.invalidate();
83
+ Object.assign(err, { status: 503 });
84
+ }
85
+ return reject(err);
36
86
  }
37
87
  resolve(res);
38
88
  });
@@ -11,7 +11,17 @@ const delCron = (call, callback) => {
11
11
  for (const id of call.request.ids) {
12
12
  if (data_1.scheduleStacks.has(id)) {
13
13
  logger_1.default.info('[schedule][取消定时任务] 任务ID: %s', id);
14
- (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.forEach(x => x.cancel());
14
+ // 防御性过滤历史调度栈中的空任务,
15
+ // 否则对 null 调 cancel() 会让整个取消流程抛出 UNKNOWN 错误,
16
+ // 进而导致 HTTP 端的 remove() 跳过 setCrontab(),造成 crontab.list 残留。
17
+ (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.filter((x) => x != null).forEach((x) => {
18
+ try {
19
+ x.cancel();
20
+ }
21
+ catch (error) {
22
+ logger_1.default.warn('[schedule][取消任务失败] 任务ID: %s, 错误: %s', id, (error === null || error === void 0 ? void 0 : error.message) || error);
23
+ }
24
+ });
15
25
  data_1.scheduleStacks.delete(id);
16
26
  }
17
27
  }
@@ -4,17 +4,82 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.check = void 0;
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const undici_1 = require("undici");
7
10
  const config_1 = __importDefault(require("../config"));
8
- const util_1 = require("../config/util");
11
+ function formatError(error) {
12
+ if (!(error instanceof Error)) {
13
+ return String(error);
14
+ }
15
+ const detailedError = error;
16
+ const details = [error.message, detailedError.code];
17
+ if (Array.isArray(detailedError.errors)) {
18
+ details.push(...detailedError.errors.map(formatError));
19
+ }
20
+ else if (detailedError.cause) {
21
+ details.push(formatError(detailedError.cause));
22
+ }
23
+ return [...new Set(details.filter(Boolean))].join(': ') || error.name;
24
+ }
25
+ async function getRecentSystemLog(lineLimit = 300) {
26
+ try {
27
+ const entries = await promises_1.default.readdir(config_1.default.systemLogPath);
28
+ const latestLog = entries
29
+ .filter((entry) => entry.endsWith('.log'))
30
+ .sort()
31
+ .at(-1);
32
+ if (!latestLog) {
33
+ return `No system log found in ${config_1.default.systemLogPath}`;
34
+ }
35
+ const content = await promises_1.default.readFile(path_1.default.join(config_1.default.systemLogPath, latestLog), 'utf8');
36
+ return content.split('\n').slice(-lineLimit).join('\n').trim();
37
+ }
38
+ catch (error) {
39
+ return `Unable to read system log from ${config_1.default.systemLogPath}: ${error instanceof Error ? error.message : String(error)}`;
40
+ }
41
+ }
9
42
  const check = async (call, callback) => {
43
+ var _a;
10
44
  switch (call.request.service) {
11
- case 'cron':
12
- const res = await (0, util_1.promiseExec)(`curl -s --noproxy '*' http://localhost:${config_1.default.port}/api/system`);
13
- if (res.includes('200')) {
14
- return callback(null, { status: 1 });
45
+ // Local scheduler liveness only: never call HTTP from this probe.
46
+ case 'scheduler':
47
+ return callback(null, { status: 1 });
48
+ case 'cron': {
49
+ const healthUrl = `http://localhost:${config_1.default.port}${config_1.default.baseUrl || ''}/api/health`;
50
+ let failure = '';
51
+ try {
52
+ const response = await (0, undici_1.request)(healthUrl, {
53
+ method: 'GET',
54
+ headersTimeout: 5000,
55
+ bodyTimeout: 5000,
56
+ });
57
+ const body = (await response.body.json());
58
+ if (response.statusCode >= 200 &&
59
+ response.statusCode < 300 &&
60
+ body.code === 200 &&
61
+ ((_a = body.data) === null || _a === void 0 ? void 0 : _a.status) === 'ok') {
62
+ return callback(null, { status: 1 });
63
+ }
64
+ failure = `HTTP ${response.statusCode}: ${JSON.stringify(body)}`;
65
+ }
66
+ catch (error) {
67
+ failure = formatError(error);
15
68
  }
16
- const qinglongErrLog = await (0, util_1.promiseExec)(`tail -n 300 ~/.pm2/logs/qinglong-error.log`);
17
- return callback(new Error(`${qinglongErrLog || ''}\n${res}`.trim()));
69
+ const systemLog = await getRecentSystemLog();
70
+ const containerHint = process.env.QL_CONTAINER === 'true'
71
+ ? 'PM2 file logging is disabled in containers. Check `docker logs <container>` for early startup errors.'
72
+ : 'Check `pm2 logs qinglong --lines 300` for early startup errors.';
73
+ return callback(new Error([
74
+ `HTTP health check failed: ${healthUrl}`,
75
+ failure,
76
+ containerHint,
77
+ `Recent system log (${config_1.default.systemLogPath}):`,
78
+ systemLog,
79
+ ]
80
+ .filter(Boolean)
81
+ .join('\n')));
82
+ }
18
83
  default:
19
84
  return callback(null, { status: 1 });
20
85
  }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setConcurrency = void 0;
7
+ const grpc_js_1 = require("@grpc/grpc-js");
8
+ const os_1 = __importDefault(require("os"));
9
+ const pLimit_1 = __importDefault(require("../shared/pLimit"));
10
+ async function setConcurrency(call, callback) {
11
+ const limit = call.request.concurrency;
12
+ if (!Number.isInteger(limit) || limit < 0 || limit > 2147483647) {
13
+ callback(Object.assign(new Error('Invalid concurrency'), {
14
+ code: grpc_js_1.status.INVALID_ARGUMENT,
15
+ }), null);
16
+ return;
17
+ }
18
+ try {
19
+ await pLimit_1.default.setCustomLimit(limit || Math.max(os_1.default.cpus().length, 4));
20
+ callback(null, {});
21
+ }
22
+ catch (error) {
23
+ callback(error, null);
24
+ }
25
+ }
26
+ exports.setConcurrency = setConcurrency;
27
+ //# sourceMappingURL=setConcurrency.js.map
@@ -1,33 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
8
  var __metadata = (this && this.__metadata) || function (k, v) {
32
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
10
  };
@@ -36,43 +13,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
15
  const typedi_1 = require("typedi");
39
- const path_1 = __importStar(require("path"));
40
16
  const config_1 = __importDefault(require("../config"));
41
17
  const util_1 = require("../config/util");
42
18
  const i18n_1 = require("../shared/i18n");
43
19
  const undici_1 = require("undici");
20
+ const fileAccess_1 = require("../shared/fileAccess");
44
21
  let ConfigService = class ConfigService {
45
22
  constructor() { }
46
23
  async getFile(filePath, res) {
47
24
  let content = '';
48
- if (!filePath) {
49
- return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
50
- }
51
- const normalized = path_1.default.normalize(filePath);
52
- if (normalized.startsWith('..') || path_1.default.isAbsolute(normalized)) {
25
+ if (!filePath || filePath.startsWith('data/scripts/')) {
53
26
  return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
54
27
  }
55
- const resolvedRoot = path_1.default.resolve(config_1.default.rootPath, normalized);
56
- const resolvedConfig = path_1.default.resolve(config_1.default.configPath, normalized);
57
- const isValidPath = resolvedRoot.startsWith(config_1.default.scriptPath) ||
58
- resolvedRoot.startsWith(config_1.default.configPath) ||
59
- resolvedConfig.startsWith(config_1.default.scriptPath) ||
60
- resolvedConfig.startsWith(config_1.default.configPath);
61
- if (!isValidPath) {
62
- return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
63
- }
64
- if (config_1.default.blackFileList.includes(path_1.default.basename(normalized))) {
28
+ const resolved = (0, fileAccess_1.resolveFileAccess)(config_1.default.configPath, [filePath], config_1.default.blackFileList);
29
+ if (!resolved) {
65
30
  return res.send({ code: 403, message: (0, i18n_1.t)('文件无法访问') });
66
31
  }
67
32
  if (filePath.startsWith('sample/')) {
68
33
  const res = await (0, undici_1.request)(`https://gitlab.com/whyour/qinglong/-/raw/master/${filePath}`);
69
34
  content = await res.body.text();
70
35
  }
71
- else if (filePath.startsWith('data/scripts/')) {
72
- content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, filePath));
73
- }
74
36
  else {
75
- content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.configPath, filePath));
37
+ content = await (0, util_1.getFileContentByName)(resolved);
76
38
  }
77
39
  res.send({ code: 200, data: content });
78
40
  }