@whyour/qinglong 2.21.0-8 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) 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 +6 -1
  7. package/back/protos/cron.proto +4 -1
  8. package/docker/Dockerfile +31 -12
  9. package/docker/Dockerfile.310 +31 -12
  10. package/docker/Dockerfile.debian +22 -14
  11. package/docker/Dockerfile.debian310 +24 -14
  12. package/docker/build-manifest.cjs +28 -0
  13. package/docker/verify-build.cjs +49 -0
  14. package/docs/releases/2.22.0-validation.md +49 -0
  15. package/docs/releases/2.22.0.md +54 -0
  16. package/ecosystem.config.js +10 -1
  17. package/package.json +11 -6
  18. package/sample/config.sample.sh +10 -0
  19. package/sample/notify.js +54 -0
  20. package/sample/notify.py +37 -0
  21. package/scripts/benchmark-execution.cjs +96 -0
  22. package/scripts/write-build-info.cjs +27 -0
  23. package/shell/api.sh +34 -13
  24. package/shell/check.sh +59 -19
  25. package/shell/lang/en.sh +6 -0
  26. package/shell/lang/zh.sh +6 -0
  27. package/shell/node_path_cache.sh +128 -0
  28. package/shell/otask.sh +7 -1
  29. package/shell/preload/sitecustomize.js +5 -1
  30. package/shell/share.sh +25 -8
  31. package/shell/start.sh +6 -3
  32. package/shell/task.sh +13 -3
  33. package/shell/update.sh +65 -4
  34. package/static/build/api/clientIp.js +42 -0
  35. package/static/build/api/config.js +8 -16
  36. package/static/build/api/cron.js +38 -2
  37. package/static/build/api/dashboard.js +37 -0
  38. package/static/build/api/health.js +2 -2
  39. package/static/build/api/index.js +4 -0
  40. package/static/build/api/log.js +30 -19
  41. package/static/build/api/retention.js +63 -0
  42. package/static/build/api/script.js +23 -22
  43. package/static/build/api/subscription.js +16 -2
  44. package/static/build/api/system.js +25 -2
  45. package/static/build/api/user.js +75 -15
  46. package/static/build/app.js +54 -45
  47. package/static/build/bootstrap/database.js +51 -0
  48. package/static/build/config/const.js +1 -0
  49. package/static/build/config/share.js +5 -4
  50. package/static/build/config/util.js +133 -38
  51. package/static/build/data/cron.js +1 -0
  52. package/static/build/data/notify.js +11 -1
  53. package/static/build/loaders/app.js +2 -0
  54. package/static/build/loaders/db.js +3 -33
  55. package/static/build/loaders/deps.js +29 -0
  56. package/static/build/loaders/express.js +30 -21
  57. package/static/build/loaders/initData.js +10 -7
  58. package/static/build/loaders/sock.js +72 -6
  59. package/static/build/middlewares/monitoring.js +12 -33
  60. package/static/build/middlewares/protectedPathCase.js +17 -0
  61. package/static/build/protos/api.js +56 -2
  62. package/static/build/protos/cron.js +21 -4
  63. package/static/build/protos/health.js +1 -1
  64. package/static/build/schedule/addCron.js +9 -0
  65. package/static/build/schedule/api.js +5 -2
  66. package/static/build/schedule/client.js +38 -6
  67. package/static/build/schedule/health.js +72 -7
  68. package/static/build/services/config.js +5 -42
  69. package/static/build/services/cron.js +338 -199
  70. package/static/build/services/dependence.js +47 -0
  71. package/static/build/services/grpc.js +1 -1
  72. package/static/build/services/health.js +4 -7
  73. package/static/build/services/http.js +8 -2
  74. package/static/build/services/log.js +2 -3
  75. package/static/build/services/metrics.js +46 -14
  76. package/static/build/services/notify.js +26 -0
  77. package/static/build/services/retention.js +123 -0
  78. package/static/build/services/schedule.js +57 -33
  79. package/static/build/services/script.js +4 -5
  80. package/static/build/services/subscription.js +55 -34
  81. package/static/build/services/system.js +37 -9
  82. package/static/build/services/user.js +213 -25
  83. package/static/build/shared/auth.js +18 -5
  84. package/static/build/shared/authMutation.js +17 -0
  85. package/static/build/shared/childProcess.js +82 -0
  86. package/static/build/shared/clientIp.js +27 -0
  87. package/static/build/shared/errors.js +9 -0
  88. package/static/build/shared/fileAccess.js +60 -0
  89. package/static/build/shared/i18n.js +12 -5
  90. package/static/build/shared/logReader.js +85 -0
  91. package/static/build/shared/logStreamManager.js +80 -60
  92. package/static/build/shared/password.js +30 -0
  93. package/static/build/shared/retention.js +58 -0
  94. package/static/build/shared/runCron.js +28 -15
  95. package/static/build/shared/schedulerMutationLock.js +44 -0
  96. package/static/build/shared/schedulerReadiness.js +82 -0
  97. package/static/build/shared/schemaMigrations.js +58 -0
  98. package/static/build/shared/startupProcess.js +48 -0
  99. package/static/build/shared/store.js +7 -0
  100. package/static/build/shared/trustProxy.js +119 -0
  101. package/static/build/validation/schedule.js +3 -3
  102. package/static/dist/{1885.e1ea09f6.async.js → 1885.b8f427bf.async.js} +1 -1
  103. package/static/dist/2031.6af40025.async.js +1 -0
  104. package/static/dist/2693.51c2636b.async.js +1 -0
  105. package/static/dist/{2890.9e373f5b.async.js → 2890.add55e85.async.js} +1 -1
  106. package/static/dist/2901.2ca95295.async.js +1 -0
  107. package/static/dist/445.a65ff63b.async.js +1 -0
  108. package/static/dist/4736.1d2b5cb6.async.js +1 -0
  109. package/static/dist/{4859.6592cebb.async.js → 4859.97d6653c.async.js} +1 -1
  110. package/static/dist/{6013.4e38de36.async.js → 6013.db535339.async.js} +1 -1
  111. package/static/dist/6212.9e6d9913.async.js +1 -0
  112. package/static/dist/{6339.ab305e96.async.js → 6431.4603ad0e.async.js} +1 -1
  113. package/static/dist/{6872.42f939f1.async.js → 6872.a503ef55.async.js} +1 -1
  114. package/static/dist/7231.f7e5b668.async.js +1 -0
  115. package/static/dist/{7355.f9f263d8.async.js → 7355.fca746f5.async.js} +1 -1
  116. package/static/dist/{7508.7dcee91c.async.js → 7508.d90eac63.async.js} +1 -1
  117. package/static/dist/{7984.594296a5.async.js → 7984.eaac7402.async.js} +1 -1
  118. package/static/dist/8844.a0fef08e.async.js +1 -0
  119. package/static/dist/index.html +2 -2
  120. package/static/dist/layouts__index.633d3553.async.js +1 -0
  121. package/static/dist/preload_helper.cf7de3fa.js +1 -0
  122. package/static/dist/{src__pages__config__index.a22ff7dc.async.js → src__pages__config__index.9aba4054.async.js} +1 -1
  123. package/static/dist/src__pages__crontab__detail.86b2eebb.async.js +1 -0
  124. package/static/dist/src__pages__crontab__index.ae4e06f2.async.js +1 -0
  125. package/static/dist/{src__pages__crontab__logModal.831d5e4b.async.js → src__pages__crontab__logModal.930535e2.async.js} +1 -1
  126. package/static/dist/src__pages__crontab__modal.a2c8fdcc.async.js +1 -0
  127. package/static/dist/src__pages__crontab__viewCreateModal.7b4f9cbe.async.js +1 -0
  128. package/static/dist/src__pages__crontab__viewManageModal.cd454ea0.async.js +1 -0
  129. package/static/dist/src__pages__dashboard__index.243c5a35.async.js +1 -0
  130. package/static/dist/src__pages__dashboard__taskResultModal.7795d6e1.async.js +1 -0
  131. package/static/dist/src__pages__dependence__index.874d501f.async.js +1 -0
  132. package/static/dist/src__pages__dependence__logModal.154efe7a.async.js +1 -0
  133. package/static/dist/src__pages__dependence__modal.a29c1a0f.async.js +1 -0
  134. package/static/dist/{src__pages__diff__index.013b7c75.async.js → src__pages__diff__index.1714b941.async.js} +1 -1
  135. package/static/dist/src__pages__env__editNameModal.c13d47d2.async.js +1 -0
  136. package/static/dist/src__pages__env__index.fd6fd2b0.async.js +1 -0
  137. package/static/dist/src__pages__env__modal.4d71adb3.async.js +1 -0
  138. package/static/dist/src__pages__error__index.aae50c94.async.js +1 -0
  139. package/static/dist/src__pages__initialization__index.82a2e967.async.js +1 -0
  140. package/static/dist/src__pages__log__index.71250e0d.async.js +1 -0
  141. package/static/dist/{src__pages__login__index.8c813eb1.async.js → src__pages__login__index.a0fd5ed8.async.js} +1 -1
  142. package/static/dist/src__pages__script__editModal.22acdf7c.async.js +1 -0
  143. package/static/dist/src__pages__script__editNameModal.1a521cc0.async.js +1 -0
  144. package/static/dist/src__pages__script__index.a18b2692.async.js +1 -0
  145. package/static/dist/src__pages__script__renameModal.0ab029e7.async.js +1 -0
  146. package/static/dist/src__pages__script__saveModal.8965b74c.async.js +1 -0
  147. package/static/dist/src__pages__script__setting.35ad4f02.async.js +1 -0
  148. package/static/dist/src__pages__setting__appModal.7eaeb9d3.async.js +1 -0
  149. package/static/dist/{src__pages__setting__checkUpdate.34d773f2.async.js → src__pages__setting__checkUpdate.d175b154.async.js} +1 -1
  150. package/static/dist/src__pages__setting__clientIp.3a8711ed.async.js +1 -0
  151. package/static/dist/src__pages__setting__dependence.9c0f749b.async.js +1 -0
  152. package/static/dist/src__pages__setting__index.cb397741.async.js +1 -0
  153. package/static/dist/src__pages__setting__loginLog.e0a1f54d.async.js +1 -0
  154. package/static/dist/src__pages__setting__notification.2ffe4e5a.async.js +1 -0
  155. package/static/dist/src__pages__setting__other.3d0b8492.async.js +1 -0
  156. package/static/dist/{src__pages__setting__progress.8823ac90.async.js → src__pages__setting__progress.2ccae3d7.async.js} +1 -1
  157. package/static/dist/src__pages__setting__security.e2d71ebb.async.js +1 -0
  158. package/static/dist/src__pages__setting__systemLog.b3046955.async.js +1 -0
  159. package/static/dist/src__pages__subscription__index.43086a06.async.js +1 -0
  160. package/static/dist/src__pages__subscription__logModal.cdba5139.async.js +1 -0
  161. package/static/dist/src__pages__subscription__modal.38991e1e.async.js +1 -0
  162. package/static/dist/{umi.a54a59f6.js → umi.fc019050.js} +1 -1
  163. package/test/back/auth-security.test.cjs +74 -0
  164. package/test/back/build-provenance.test.cjs +150 -0
  165. package/test/back/cron-log-name.test.cjs +110 -0
  166. package/test/back/cron-validation.test.cjs +45 -0
  167. package/test/back/dashboard-failures.test.cjs +173 -0
  168. package/test/back/database-bootstrap.test.cjs +193 -0
  169. package/test/back/dependence-cache-status.test.cjs +125 -0
  170. package/test/back/deprecated-file-routes.test.cjs +82 -0
  171. package/test/back/ecosystem.test.cjs +28 -0
  172. package/test/back/env-name-parsing.test.cjs +96 -0
  173. package/test/back/execution-lifecycle.test.cjs +236 -0
  174. package/test/back/file-access-security.test.cjs +47 -0
  175. package/test/back/fileTreeListing.test.cjs +57 -0
  176. package/test/back/grpc-cron-response.test.cjs +60 -0
  177. package/test/back/http-exclusive-listen.test.cjs +31 -0
  178. package/test/back/http-security.test.cjs +213 -0
  179. package/test/back/listen-security.test.cjs +67 -0
  180. package/test/back/log-path-security.test.cjs +158 -0
  181. package/test/back/logReader.test.cjs +72 -0
  182. package/test/back/manual-execution.test.cjs +85 -0
  183. package/test/back/manual-stop-claim.test.cjs +220 -0
  184. package/test/back/metrics.test.cjs +34 -0
  185. package/test/back/monitoring.test.cjs +73 -0
  186. package/test/back/node-path-cache.test.cjs +173 -0
  187. package/test/back/node-path-lock.test.cjs +178 -0
  188. package/test/back/npm-publication.test.cjs +70 -0
  189. package/test/back/primary-apm.test.cjs +24 -0
  190. package/test/back/process-exit-state.test.cjs +81 -0
  191. package/test/back/process-stop-signal.test.cjs +77 -0
  192. package/test/back/protected-path-case.test.cjs +58 -0
  193. package/test/back/qlServiceLogCommand.test.cjs +128 -0
  194. package/test/back/retention.test.cjs +131 -0
  195. package/test/back/role-loading.test.cjs +118 -0
  196. package/test/back/schedule-health.test.cjs +86 -0
  197. package/test/back/scheduler-file-lock.test.cjs +51 -0
  198. package/test/back/scheduler-mutation.test.cjs +312 -0
  199. package/test/back/scheduler-readiness.test.cjs +85 -0
  200. package/test/back/scheduler-reconciliation.test.cjs +152 -0
  201. package/test/back/scheduler-rpc-timeout.test.cjs +49 -0
  202. package/test/back/schema-migrations.test.cjs +127 -0
  203. package/test/back/shell-api-parsing.test.cjs +184 -0
  204. package/test/back/sock-polling.test.cjs +297 -0
  205. package/test/back/sock-security.test.cjs +72 -0
  206. package/test/back/start-env-preservation.test.cjs +53 -0
  207. package/test/back/stop-failure-feedback.test.cjs +158 -0
  208. package/test/back/stop-race.test.cjs +167 -0
  209. package/test/back/subscription-cleanup.test.cjs +53 -0
  210. package/test/back/subscription-stop-state.test.cjs +66 -0
  211. package/test/back/system-dependence-cache.test.cjs +126 -0
  212. package/test/back/task-time.test.cjs +116 -0
  213. package/test/back/user-api.test.cjs +99 -0
  214. package/test/back/user-security.test.cjs +248 -0
  215. package/test/back/worker-apm.test.cjs +84 -0
  216. package/test/back/wpush-grpc.test.cjs +115 -0
  217. package/test/front/cron-log-pagination.test.cjs +214 -0
  218. package/test/front/http-auth.test.cjs +152 -0
  219. package/test/front/http-error.test.cjs +29 -0
  220. package/test/helpers/load-security-module.cjs +42 -0
  221. package/version.yaml +19 -34
  222. package/CLAUDE.md +0 -43
  223. package/static/dist/1147.62793604.async.js +0 -1
  224. package/static/dist/134.54df9e38.async.js +0 -1
  225. package/static/dist/2208.85285476.async.js +0 -1
  226. package/static/dist/2286.f371c743.async.js +0 -1
  227. package/static/dist/3191.545ab873.async.js +0 -1
  228. package/static/dist/4902.555f92ab.async.js +0 -1
  229. package/static/dist/5520.ff2cfd6b.async.js +0 -1
  230. package/static/dist/6431.c50479be.async.js +0 -1
  231. package/static/dist/8826.db34ad8d.async.js +0 -1
  232. package/static/dist/layouts__index.a7a2bfe0.async.js +0 -1
  233. package/static/dist/preload_helper.3048fe5b.js +0 -1
  234. package/static/dist/src__pages__crontab__detail.b98f0084.async.js +0 -1
  235. package/static/dist/src__pages__crontab__index.68e78a33.async.js +0 -1
  236. package/static/dist/src__pages__crontab__modal.f7041c7c.async.js +0 -1
  237. package/static/dist/src__pages__crontab__viewCreateModal.4d589f66.async.js +0 -1
  238. package/static/dist/src__pages__crontab__viewManageModal.0e317746.async.js +0 -1
  239. package/static/dist/src__pages__dashboard__index.58177357.async.js +0 -1
  240. package/static/dist/src__pages__dependence__index.b7bbc795.async.js +0 -1
  241. package/static/dist/src__pages__dependence__logModal.0681830b.async.js +0 -1
  242. package/static/dist/src__pages__dependence__modal.f7bb47ba.async.js +0 -1
  243. package/static/dist/src__pages__env__editNameModal.48715576.async.js +0 -1
  244. package/static/dist/src__pages__env__index.452cdc47.async.js +0 -1
  245. package/static/dist/src__pages__env__modal.e1234834.async.js +0 -1
  246. package/static/dist/src__pages__error__index.dedb2b90.async.js +0 -1
  247. package/static/dist/src__pages__initialization__index.22620a77.async.js +0 -1
  248. package/static/dist/src__pages__log__index.9c66639f.async.js +0 -1
  249. package/static/dist/src__pages__script__editModal.cbf4ec0e.async.js +0 -1
  250. package/static/dist/src__pages__script__editNameModal.532a3044.async.js +0 -1
  251. package/static/dist/src__pages__script__index.1fc20f22.async.js +0 -1
  252. package/static/dist/src__pages__script__renameModal.5cdde919.async.js +0 -1
  253. package/static/dist/src__pages__script__saveModal.5ffed35f.async.js +0 -1
  254. package/static/dist/src__pages__script__setting.1a82c6d7.async.js +0 -1
  255. package/static/dist/src__pages__setting__appModal.43b7758a.async.js +0 -1
  256. package/static/dist/src__pages__setting__dependence.9c04c79a.async.js +0 -1
  257. package/static/dist/src__pages__setting__index.7e070838.async.js +0 -1
  258. package/static/dist/src__pages__setting__loginLog.cea6056c.async.js +0 -1
  259. package/static/dist/src__pages__setting__notification.bac481c2.async.js +0 -1
  260. package/static/dist/src__pages__setting__other.707cfafe.async.js +0 -1
  261. package/static/dist/src__pages__setting__security.b7235753.async.js +0 -1
  262. package/static/dist/src__pages__setting__systemLog.b81a8c1d.async.js +0 -1
  263. package/static/dist/src__pages__subscription__index.d0ab2abc.async.js +0 -1
  264. package/static/dist/src__pages__subscription__logModal.3864b37f.async.js +0 -1
  265. package/static/dist/src__pages__subscription__modal.562448e2.async.js +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
3
  "packageManager": "pnpm@8.3.1",
4
- "version": "2.21.0-8",
4
+ "version": "2.22.0",
5
5
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,17 +13,22 @@
13
13
  "url": "https://github.com/whyour/qinglong/issues"
14
14
  },
15
15
  "scripts": {
16
+ "build:cli": "node cli/scripts/build.cjs",
17
+ "check:cli": "npm --prefix cli run check",
18
+ "test:cli": "npm run build:cli && node cli/scripts/test.cjs",
19
+ "cli": "node cli/dist/index.js",
16
20
  "start": "concurrently -n w: npm:start:*",
17
21
  "start:back": "nodemon ./back/app.ts",
18
22
  "start:front": "max dev",
19
23
  "build:front": "max build",
20
24
  "build:back": "tsc -p back/tsconfig.json",
25
+ "test": "TS_NODE_PROJECT=back/tsconfig.json node -r ts-node/register/transpile-only --test test/back/*.test.cjs test/front/*.test.cjs",
26
+ "benchmark:execution": "TS_NODE_PROJECT=back/tsconfig.json node -r ts-node/register/transpile-only scripts/benchmark-execution.cjs",
27
+ "build:info": "node scripts/write-build-info.cjs",
21
28
  "panel": "npm run build:back && node static/build/app.js",
22
29
  "gen:proto": "protoc --experimental_allow_proto3_optional --plugin=./node_modules/.bin/protoc-gen-ts_proto ./back/protos/*.proto --ts_proto_out=./ --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true,snakeToCamel=false",
23
30
  "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
24
- "postinstall": "max setup 2>/dev/null || true",
25
- "test": "umi-test",
26
- "test:coverage": "umi-test --coverage"
31
+ "postinstall": "max setup 2>/dev/null || true"
27
32
  },
28
33
  "gitHooks": {
29
34
  "pre-commit": "lint-staged"
@@ -67,7 +72,7 @@
67
72
  }
68
73
  },
69
74
  "overrides": {
70
- "sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
75
+ "sqlite3": "npm:@whyour/sqlite3@1.1.2",
71
76
  "@codemirror/state": "6.5.4",
72
77
  "@codemirror/view": "6.39.16"
73
78
  }
@@ -111,7 +116,7 @@
111
116
  "request-ip": "3.3.0",
112
117
  "sequelize": "^6.37.5",
113
118
  "sockjs": "^0.3.24",
114
- "sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
119
+ "sqlite3": "npm:@whyour/sqlite3@1.1.2",
115
120
  "toad-scheduler": "^3.0.1",
116
121
  "typedi": "^0.10.0",
117
122
  "undici": "^7.9.0",
@@ -276,3 +276,13 @@ export OPENILINK_HUB_URL=""
276
276
  export OPENILINK_CONTEXT_TOKEN=""
277
277
 
278
278
  ## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
279
+
280
+ ## 23. WPUSH
281
+ ## 官方文档: https://wpush.cn/docs
282
+ ## WPUSH_APIKEY (必填) 在 https://wpush.cn/settings 获取,以 WPUSH 开头
283
+ export WPUSH_APIKEY=""
284
+ ## 推送渠道,支持 wechat/app/sms/mail/webhook/dingtalk/feishu/wechat_work/clawbot/qqbot,默认 wechat
285
+ export WPUSH_CHANNEL="wechat"
286
+ ## 可选,Topic 广播编码;填写后按 Topic 推送
287
+ export WPUSH_TOPIC_CODE=""
288
+
package/sample/notify.js CHANGED
@@ -162,6 +162,11 @@ const push_config = {
162
162
  OPENILINK_APP_TOKEN: '', // OpeniLink 的 app_token,在 OpeniLink Hub 后台安装 App 后获取
163
163
  OPENILINK_HUB_URL: '', // OpeniLink Hub 地址,默认为 https://hub.openilink.com,自建 Hub 时填写自己的地址
164
164
  OPENILINK_CONTEXT_TOKEN: '', // OpeniLink 的 context_token,用于标识消息会话上下文,可从消息事件中获取
165
+
166
+ // WPUSH 官方文档: https://wpush.cn/docs
167
+ WPUSH_APIKEY: '', // WPUSH 的 API Key,在 https://wpush.cn/settings 获取
168
+ WPUSH_CHANNEL: 'wechat', // 推送渠道,支持 wechat/app/sms/mail/webhook/dingtalk/feishu/wechat_work/clawbot/qqbot
169
+ WPUSH_TOPIC_CODE: '', // 可选,Topic 广播编码
165
170
  };
166
171
 
167
172
  for (const key in push_config) {
@@ -1494,6 +1499,54 @@ function wxPusherSptNotify(text, desp) {
1494
1499
  });
1495
1500
  }
1496
1501
 
1502
+
1503
+
1504
+ function wpushNotify(text, desp) {
1505
+ return new Promise((resolve) => {
1506
+ const { WPUSH_APIKEY, WPUSH_CHANNEL, WPUSH_TOPIC_CODE } = push_config;
1507
+ if (WPUSH_APIKEY) {
1508
+ const body = {
1509
+ apikey: `${WPUSH_APIKEY}`,
1510
+ title: `${text}`,
1511
+ content: `${desp}`,
1512
+ channel: `${WPUSH_CHANNEL || 'wechat'}`,
1513
+ };
1514
+ if (WPUSH_TOPIC_CODE) {
1515
+ body.topic_code = WPUSH_TOPIC_CODE;
1516
+ }
1517
+ const options = {
1518
+ url: `https://api.wpush.cn/api/v1/send`,
1519
+ body: JSON.stringify(body),
1520
+ headers: {
1521
+ 'Content-Type': 'application/json',
1522
+ },
1523
+ timeout,
1524
+ };
1525
+ $.post(options, (err, resp, data) => {
1526
+ try {
1527
+ if (err) {
1528
+ console.log('WPUSH 发送通知消息失败!\n', err);
1529
+ } else {
1530
+ if (data.code === 0) {
1531
+ console.log('WPUSH 发送通知消息成功!');
1532
+ } else {
1533
+ console.log(
1534
+ `WPUSH 发送通知消息异常:${data.message || JSON.stringify(data)}`,
1535
+ );
1536
+ }
1537
+ }
1538
+ } catch (e) {
1539
+ $.logErr(e, resp);
1540
+ } finally {
1541
+ resolve(data);
1542
+ }
1543
+ });
1544
+ } else {
1545
+ resolve();
1546
+ }
1547
+ });
1548
+ }
1549
+
1497
1550
  function openiLinkNotify(text, desp) {
1498
1551
  return new Promise((resolve) => {
1499
1552
  const { OPENILINK_APP_TOKEN, OPENILINK_HUB_URL, OPENILINK_CONTEXT_TOKEN } =
@@ -1674,6 +1727,7 @@ async function sendNotify(text, desp, params = {}) {
1674
1727
  wxPusherNotify(text, desp), // wxpusher
1675
1728
  wxPusherSptNotify(text, desp), // wxpusher SPT
1676
1729
  openiLinkNotify(text, desp), // OpeniLink
1730
+ wpushNotify(text, desp), // WPUSH
1677
1731
  ]);
1678
1732
  }
1679
1733
 
package/sample/notify.py CHANGED
@@ -147,6 +147,11 @@ push_config = {
147
147
  'OPENILINK_APP_TOKEN': '', # OpeniLink 的 app_token,在 OpeniLink Hub 后台安装 App 后获取 官方文档: https://openilink.com/docs/hub/apps
148
148
  'OPENILINK_HUB_URL': '', # OpeniLink Hub 地址,默认为 https://hub.openilink.com,自建 Hub 时填写自己的地址
149
149
  'OPENILINK_CONTEXT_TOKEN': '', # OpeniLink 的 context_token,用于标识消息会话上下文,可从消息事件中获取
150
+
151
+ # WPUSH 官方文档: https://wpush.cn/docs
152
+ 'WPUSH_APIKEY': '', # WPUSH 的 API Key,在 https://wpush.cn/settings 获取
153
+ 'WPUSH_CHANNEL': 'wechat', # 推送渠道,支持 wechat/app/sms/mail/webhook/dingtalk/feishu/wechat_work/clawbot/qqbot
154
+ 'WPUSH_TOPIC_CODE': '', # 可选,Topic 广播编码
150
155
  }
151
156
  # fmt: on
152
157
 
@@ -956,6 +961,36 @@ def wxpusher_spt(title: str, content: str) -> None:
956
961
  print(f"wxpusher SPT 推送失败!错误信息:{response.get('msg')}")
957
962
 
958
963
 
964
+
965
+ def wpush(title: str, content: str) -> None:
966
+ """
967
+ 通过 WPUSH 推送消息。
968
+ 官方文档: https://wpush.cn/docs
969
+ """
970
+ if not push_config.get("WPUSH_APIKEY"):
971
+ return
972
+
973
+ print("WPUSH 服务启动")
974
+
975
+ url = "https://api.wpush.cn/api/v1/send"
976
+ data = {
977
+ "apikey": push_config.get("WPUSH_APIKEY"),
978
+ "title": title,
979
+ "content": content,
980
+ "channel": push_config.get("WPUSH_CHANNEL") or "wechat",
981
+ }
982
+ if push_config.get("WPUSH_TOPIC_CODE"):
983
+ data["topic_code"] = push_config.get("WPUSH_TOPIC_CODE")
984
+
985
+ headers = {"Content-Type": "application/json"}
986
+ response = requests.post(url=url, json=data, headers=headers, timeout=15).json()
987
+
988
+ if response.get("code") == 0:
989
+ print("WPUSH 推送成功!")
990
+ else:
991
+ print(f'WPUSH 推送失败!错误信息:{response.get("message") or response}')
992
+
993
+
959
994
  def openilink(title: str, content: str) -> None:
960
995
  """
961
996
  通过 OpeniLink 推送消息。
@@ -1162,6 +1197,8 @@ def add_notify_function():
1162
1197
  notify_function.append(wxpusher_spt)
1163
1198
  if push_config.get("OPENILINK_APP_TOKEN"):
1164
1199
  notify_function.append(openilink)
1200
+ if push_config.get("WPUSH_APIKEY"):
1201
+ notify_function.append(wpush)
1165
1202
  if not notify_function:
1166
1203
  print(f"无推送渠道,请检查通知变量是否正确")
1167
1204
  return notify_function
@@ -0,0 +1,96 @@
1
+ // Microbenchmark of the process observer, not a container or scheduler benchmark.
2
+ const fs = require('node:fs');
3
+ const os = require('node:os');
4
+ const crypto = require('node:crypto');
5
+ const { spawn, execFileSync } = require('node:child_process');
6
+ const { performance } = require('node:perf_hooks');
7
+ const { observeChildProcess } = require('../back/shared/childProcess');
8
+
9
+ const args = process.argv.slice(2).filter((arg) => arg !== '--');
10
+ const runsArg = args.find((arg) => arg.startsWith('--runs='));
11
+ const runs = runsArg ? Number(runsArg.slice(7)) : 30;
12
+ if (!Number.isInteger(runs) || runs < 3 || runs > 10000)
13
+ throw new Error('runs must be between 3 and 10000');
14
+ const output = args.find((arg) => arg.startsWith('--output='))?.slice(9);
15
+ const git = (...args) => execFileSync('git', args, { encoding: 'utf8' }).trim();
16
+ const scenarios = [
17
+ { name: 'empty-node', command: '' },
18
+ {
19
+ name: 'log-1MiB',
20
+ command: 'process.stdout.write("x".repeat(1024 * 1024))',
21
+ bytes: 1024 * 1024,
22
+ },
23
+ { name: 'spawn-failure', shell: '/nonexistent-ql-benchmark-shell' },
24
+ ];
25
+
26
+ (async () => {
27
+ const report = {
28
+ schema: 1,
29
+ observerSha256: crypto
30
+ .createHash('sha256')
31
+ .update(fs.readFileSync('back/shared/childProcess.ts'))
32
+ .digest('hex'),
33
+ benchmarkSha256: crypto
34
+ .createHash('sha256')
35
+ .update(fs.readFileSync(__filename))
36
+ .digest('hex'),
37
+ scope:
38
+ 'local process observer only; parent CPU excludes child CPU; no panel/container load measured',
39
+ sourceCommit: git('rev-parse', 'HEAD'),
40
+ dirty: git('status', '--porcelain') !== '',
41
+ lockfileSha256: crypto
42
+ .createHash('sha256')
43
+ .update(fs.readFileSync('pnpm-lock.yaml'))
44
+ .digest('hex'),
45
+ node: process.version,
46
+ platform: process.platform,
47
+ arch: process.arch,
48
+ cpu: os.cpus()[0]?.model,
49
+ cores: os.cpus().length,
50
+ timestamp: new Date().toISOString(),
51
+ runs,
52
+ scenarios: [],
53
+ };
54
+ for (const scenario of scenarios) {
55
+ const samples = [];
56
+ const cpuStart = process.cpuUsage();
57
+ for (let index = 0; index < runs; index++) {
58
+ const start = performance.now();
59
+ let bytes = 0;
60
+ const child = scenario.shell
61
+ ? spawn('true', { shell: scenario.shell })
62
+ : spawn(process.execPath, ['-e', scenario.command]);
63
+ const result = await observeChildProcess(child, {
64
+ onStdout: async (chunk) => {
65
+ bytes += Buffer.byteLength(chunk);
66
+ },
67
+ }).completed;
68
+ if (scenario.shell ? !result.error : result.error || result.code !== 0)
69
+ throw new Error(`Unexpected result: ${scenario.name}`);
70
+ if (bytes !== (scenario.bytes || 0))
71
+ throw new Error(`Output loss: ${scenario.name}`);
72
+ samples.push({
73
+ wallMs: performance.now() - start,
74
+ bytes,
75
+ code: result.code,
76
+ error: result.error?.message,
77
+ });
78
+ }
79
+ const sorted = samples.map((sample) => sample.wallMs).sort((a, b) => a - b);
80
+ const percentile = (p) => sorted[Math.ceil(sorted.length * p) - 1];
81
+ report.scenarios.push({
82
+ name: scenario.name,
83
+ parentCpuMicros: process.cpuUsage(cpuStart),
84
+ p50Ms: percentile(0.5),
85
+ p95Ms: percentile(0.95),
86
+ ...(runs >= 100 ? { p99Ms: percentile(0.99) } : {}),
87
+ samples,
88
+ });
89
+ }
90
+ const json = JSON.stringify(report, null, 2) + '\n';
91
+ if (output) fs.writeFileSync(output, json);
92
+ else process.stdout.write(json);
93
+ })().catch((error) => {
94
+ console.error(error);
95
+ process.exitCode = 1;
96
+ });
@@ -0,0 +1,27 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const crypto = require('node:crypto');
4
+ const { execFileSync } = require('node:child_process');
5
+ const { collectBuildFiles } = require('../docker/build-manifest.cjs');
6
+
7
+ const root = process.cwd();
8
+ for (const output of ['static/build/app.js', 'static/dist/index.html']) {
9
+ if (!fs.existsSync(path.join(root, output)))
10
+ throw new Error(`Missing build output: ${output}`);
11
+ }
12
+ const git = (...args) =>
13
+ execFileSync('git', args, { cwd: root, encoding: 'utf8' }).trim();
14
+ const manifest = {
15
+ version: 1,
16
+ files: collectBuildFiles(),
17
+ sourceCommit: git('rev-parse', 'HEAD'),
18
+ dirty: git('status', '--porcelain', '--untracked-files=all') !== '',
19
+ lockfileSha256: crypto
20
+ .createHash('sha256')
21
+ .update(fs.readFileSync('pnpm-lock.yaml'))
22
+ .digest('hex'),
23
+ };
24
+ fs.writeFileSync(
25
+ 'static/build-info.json',
26
+ JSON.stringify(manifest, null, 2) + '\n',
27
+ );
package/shell/api.sh CHANGED
@@ -10,16 +10,39 @@ create_token() {
10
10
  }
11
11
 
12
12
  get_token() {
13
- if [[ -f $file_auth_token ]]; then
14
- __ql_token__=$(cat $file_auth_token | jq -r .value)
15
- local expiration=$(cat $file_auth_token | jq -r .expiration)
16
- local currentTimeStamp=$(date +%s)
17
- if [[ $currentTimeStamp -ge $expiration ]]; then
18
- create_token
13
+ local token_data expiration token_value
14
+ local currentTimeStamp=${EPOCHSECONDS:-$(date +%s)}
15
+ if [[ -f "$file_auth_token" ]] && token_data=$(jq -er \
16
+ 'select((.expiration | type) == "number" and (.value | type) == "string" and (.value | length) > 0 and (.value | test("[\r\n]") | not)) | .expiration, .value' \
17
+ "$file_auth_token" 2>/dev/null); then
18
+ expiration=${token_data%%$'\n'*}
19
+ token_value=${token_data#*$'\n'}
20
+ if [[ "$expiration" =~ ^[1-9][0-9]{0,10}$ && -n "$token_value" && "$token_value" != *$'\n'* && "$token_value" != *$'\r'* ]] && \
21
+ (( currentTimeStamp < expiration )); then
22
+ __ql_token__=$token_value
23
+ return 0
19
24
  fi
20
- else
21
- create_token
22
25
  fi
26
+ create_token
27
+ }
28
+
29
+ # Read the status response once; preserve multiline error messages and the
30
+ # legacy code/message variables used by the shell API callers.
31
+ ql_parse_status_response() {
32
+ # Both task status and statistics endpoints normally return this exact body.
33
+ # Match the whole document; all other JSON and malformed responses still
34
+ # use jq. Keep its missing-message result for existing callers.
35
+ if [[ "$1" == '{"code":200}' ]]; then
36
+ code=200
37
+ message=null
38
+ return 0
39
+ fi
40
+ local parsed
41
+ code=""
42
+ message=""
43
+ parsed=$(jq -r '.code, .message' <<< "$1") || return $?
44
+ code=${parsed%%$'\n'*}
45
+ message=${parsed#*$'\n'}
23
46
  }
24
47
 
25
48
  add_cron_api() {
@@ -142,7 +165,7 @@ update_cron() {
142
165
  local lastExecutingTime="${5:-0}"
143
166
  local runningTime="${6:-0}"
144
167
  local exitCode="${7:-}"
145
- local currentTimeStamp=$(date +%s)
168
+ local currentTimeStamp=${EPOCHSECONDS:-$(date +%s)}
146
169
  local dataRaw="{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime"
147
170
  if [[ -n $exitCode ]]; then
148
171
  dataRaw="${dataRaw},\"exit_code\":$exitCode"
@@ -156,8 +179,7 @@ update_cron() {
156
179
  --data-raw "$dataRaw" \
157
180
  --compressed
158
181
  )
159
- code=$(echo "$api" | jq -r .code)
160
- message=$(echo "$api" | jq -r .message)
182
+ ql_parse_status_response "$api" || true
161
183
  if [[ $code != 200 ]]; then
162
184
  if [[ ! $message ]]; then
163
185
  message="$api"
@@ -240,8 +262,7 @@ record_cron_stat() {
240
262
  --data-raw "{\"ref_id\":$ref_id,\"code\":$exit_code,\"elapsed\":$elapsed}" \
241
263
  --compressed
242
264
  )
243
- code=$(echo "$api" | jq -r .code)
244
- message=$(echo "$api" | jq -r .message)
265
+ ql_parse_status_response "$api" || true
245
266
  if [[ $code != 200 ]]; then
246
267
  if [[ ! $message ]]; then
247
268
  message="$api"
package/shell/check.sh CHANGED
@@ -23,50 +23,90 @@ copy_dep() {
23
23
  }
24
24
 
25
25
  pm2_log() {
26
- t '---> pm2日志'
27
- local panelOut="/root/.pm2/logs/qinglong-out.log"
28
- local panelError="/root/.pm2/logs/qinglong-error.log"
29
- tail -n 300 "$panelOut"
30
- tail -n 300 "$panelError"
26
+ t '---> 服务诊断信息'
27
+ pm2 status || true
28
+
29
+ local systemLogDir="$dir_data/syslog"
30
+ local latestSystemLog
31
+ latestSystemLog=$(find "$systemLogDir" -maxdepth 1 -type f -name '*.log' 2>/dev/null | sort | tail -n 1)
32
+ if [[ -n "$latestSystemLog" ]]; then
33
+ t '---> 最近的系统日志: %s' "$latestSystemLog"
34
+ tail -n 300 "$latestSystemLog"
35
+ else
36
+ t '---> 未找到系统日志: %s' "$systemLogDir"
37
+ fi
38
+
39
+ if [[ "$QL_CONTAINER" == "true" ]]; then
40
+ t '---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>'
41
+ return
42
+ fi
43
+
44
+ local pm2Home="${PM2_HOME:-$HOME/.pm2}"
45
+ local panelOut="$pm2Home/logs/qinglong-out.log"
46
+ local panelError="$pm2Home/logs/qinglong-error.log"
47
+ [[ -f "$panelOut" ]] && tail -n 300 "$panelOut"
48
+ [[ -f "$panelError" ]] && tail -n 300 "$panelError"
31
49
  }
32
50
 
33
51
  check_ql() {
34
- local api=$(curl -s --noproxy "*" "http://localhost:${ql_port}")
52
+ local basePath="${ql_base_url%/}"
53
+ local api
54
+ local attempt
55
+ for ((attempt = 1; attempt <= 10; attempt++)); do
56
+ api=$(curl -s --max-time 2 --noproxy "*" "http://localhost:${ql_port}${basePath}/")
57
+ [[ $api =~ "<div id=\"root\"></div>" ]] && break
58
+ sleep 1
59
+ done
35
60
  t '\n=====> 检测面板'
36
61
  echo -e "\n\n$api\n"
37
62
  if [[ $api =~ "<div id=\"root\"></div>" ]]; then
38
63
  t '=====> 面板服务启动正常\n'
64
+ else
65
+ t '=====> 面板服务启动异常,请检查上方诊断信息\n'
66
+ return 1
39
67
  fi
40
68
  }
41
69
 
42
70
  check_pm2() {
43
- pm2_log
44
71
  local currentTimeStamp=$(date +%s)
45
- local api=$(
46
- curl -s --noproxy "*" "http://localhost:${ql_port}/api/system?t=$currentTimeStamp" \
47
- -H 'Accept: */*' \
48
- -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
49
- -H "Referer: http://localhost:${ql_port}/crontab" \
50
- -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
51
- --compressed
52
- )
72
+ local basePath="${ql_base_url%/}"
73
+ local api
74
+ local attempt
75
+ for ((attempt = 1; attempt <= 10; attempt++)); do
76
+ api=$(
77
+ curl -s --max-time 2 --noproxy "*" "http://localhost:${ql_port}${basePath}/api/health?t=$currentTimeStamp" \
78
+ -H 'Accept: */*' \
79
+ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
80
+ -H "Referer: http://localhost:${ql_port}/crontab" \
81
+ -H 'Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
82
+ --compressed
83
+ )
84
+ [[ $api == *'"code":200'* && $api == *'"status":"ok"'* ]] && break
85
+ sleep 1
86
+ done
53
87
  t '\n=====> 检测后台'
54
88
  echo -e "\n\n$api\n"
55
- if [[ $api =~ "{\"code\"" ]]; then
89
+ if [[ $api == *'"code":200'* && $api == *'"status":"ok"'* ]]; then
56
90
  t '=====> 后台服务启动正常\n'
91
+ else
92
+ pm2_log
93
+ t '=====> 后台服务启动异常,请检查上方诊断信息\n'
94
+ return 1
57
95
  fi
58
96
  }
59
97
 
60
98
  main() {
61
99
  t '=====> 开始检测'
62
- npm i -g pnpm@8.3.1 pm2 ts-node
100
+ npm i -g pnpm@8.3.1 pm2 ts-node typescript@5
63
101
 
64
102
  reset_env
65
103
  copy_dep
66
- check_ql
67
- check_pm2
68
104
  reload_pm2
105
+ local checkStatus=0
106
+ check_ql || checkStatus=1
107
+ check_pm2 || checkStatus=1
69
108
  t '\n=====> 检测结束\n'
109
+ return $checkStatus
70
110
  }
71
111
 
72
112
  main
package/shell/lang/en.sh CHANGED
@@ -82,10 +82,16 @@ declare -gA LANG_MESSAGES=(
82
82
  ['---> 复制一份 %s 为 %s\n']='---> Copying %s to %s\n'
83
83
  ['---> 通知文件复制完成\n']='---> Notification files copied\n'
84
84
  ['---> pm2日志']='---> pm2 log'
85
+ ['---> 服务诊断信息']='---> Service diagnostics'
86
+ ['---> 最近的系统日志: %s']='---> Recent system log: %s'
87
+ ['---> 未找到系统日志: %s']='---> No system log found: %s'
88
+ ['---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>']='---> PM2 logs are not persisted in containers; run docker logs --tail 300 <container> for early startup errors'
85
89
  ['\n=====> 检测面板']='\n=====> Checking panel'
86
90
  ['=====> 面板服务启动正常\n']='=====> Panel service running normally\n'
91
+ ['=====> 面板服务启动异常,请检查上方诊断信息\n']='=====> Panel failed to start; check the diagnostics above\n'
87
92
  ['\n=====> 检测后台']='\n=====> Checking backend'
88
93
  ['=====> 后台服务启动正常\n']='=====> Backend service running normally\n'
94
+ ['=====> 后台服务启动异常,请检查上方诊断信息\n']='=====> Backend failed to start; check the diagnostics above\n'
89
95
  ['=====> 开始检测']='=====> Starting check'
90
96
  ['\n=====> 检测结束\n']='\n=====> Check complete\n'
91
97
  # rmlog.sh
package/shell/lang/zh.sh CHANGED
@@ -82,10 +82,16 @@ declare -gA LANG_MESSAGES=(
82
82
  ['---> 复制一份 %s 为 %s\n']='---> 复制一份 %s 为 %s\n'
83
83
  ['---> 通知文件复制完成\n']='---> 通知文件复制完成\n'
84
84
  ['---> pm2日志']='---> pm2日志'
85
+ ['---> 服务诊断信息']='---> 服务诊断信息'
86
+ ['---> 最近的系统日志: %s']='---> 最近的系统日志: %s'
87
+ ['---> 未找到系统日志: %s']='---> 未找到系统日志: %s'
88
+ ['---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>']='---> 容器内 PM2 日志不落盘;早期启动错误请执行 docker logs --tail 300 <容器名>'
85
89
  ['\n=====> 检测面板']='\n=====> 检测面板'
86
90
  ['=====> 面板服务启动正常\n']='=====> 面板服务启动正常\n'
91
+ ['=====> 面板服务启动异常,请检查上方诊断信息\n']='=====> 面板服务启动异常,请检查上方诊断信息\n'
87
92
  ['\n=====> 检测后台']='\n=====> 检测后台'
88
93
  ['=====> 后台服务启动正常\n']='=====> 后台服务启动正常\n'
94
+ ['=====> 后台服务启动异常,请检查上方诊断信息\n']='=====> 后台服务启动异常,请检查上方诊断信息\n'
89
95
  ['=====> 开始检测']='=====> 开始检测'
90
96
  ['\n=====> 检测结束\n']='\n=====> 检测结束\n'
91
97
  # rmlog.sh