@whyour/qinglong 0.8.3 → 0.9.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 (215) hide show
  1. package/package.json +4 -3
  2. package/sample/notify.py +1 -1
  3. package/shell/share.sh +1 -1
  4. package/static/build/api/system.js +9 -0
  5. package/static/build/app.js +2 -0
  6. package/static/build/config/index.js +2 -0
  7. package/static/build/config/util.js +8 -2
  8. package/static/build/loaders/app.js +21 -10
  9. package/static/build/loaders/db.js +3 -2
  10. package/static/build/loaders/express.js +2 -0
  11. package/static/build/loaders/initFile.js +6 -0
  12. package/static/build/loaders/logger.js +18 -13
  13. package/static/build/loaders/sentry.js +1 -0
  14. package/static/build/loaders/server.js +5 -1
  15. package/static/build/public.js +3 -1
  16. package/static/build/schedule/addCron.js +2 -1
  17. package/static/build/schedule/delCron.js +5 -0
  18. package/static/build/schedule/index.js +2 -1
  19. package/static/build/services/cron.js +3 -4
  20. package/static/build/services/dependence.js +1 -1
  21. package/static/build/services/schedule.js +9 -9
  22. package/static/build/services/subscription.js +1 -1
  23. package/static/build/services/system.js +23 -0
  24. package/static/build/shared/runCron.js +4 -4
  25. package/static/dist/1186.39086229.async.js +1 -0
  26. package/static/dist/1571.94ddca13.async.js +1 -0
  27. package/static/dist/1667.94045304.async.js +1 -0
  28. package/static/dist/1925.b3032a5e.async.js +1 -0
  29. package/static/dist/2260.6b2b0020.async.js +1 -0
  30. package/static/dist/2536.282cde37.async.js +1 -0
  31. package/static/dist/2618.d4ab1f05.async.js +1 -0
  32. package/static/dist/2715.f6d4a9ed.async.js +1 -0
  33. package/static/dist/2755.f6377d52.async.js +1 -0
  34. package/static/dist/29.dd4d8489.async.js +1 -0
  35. package/static/dist/3271.e5502cf4.async.js +1 -0
  36. package/static/dist/3330.6b55d282.async.js +1 -0
  37. package/static/dist/3639.62f45f5e.async.js +1 -0
  38. package/static/dist/3669.d39d1a9d.async.js +1 -0
  39. package/static/dist/380.1bd1f124.async.js +1 -0
  40. package/static/dist/3800.fca63cfc.async.js +1 -0
  41. package/static/dist/4124.27cef0bd.async.js +1 -0
  42. package/static/dist/4163.2fc47c9d.async.js +1 -0
  43. package/static/dist/4424.73f63db5.async.js +1 -0
  44. package/static/dist/4588.46a3a31e.async.js +1 -0
  45. package/static/dist/4618.cc1776f5.async.js +1 -0
  46. package/static/dist/4658.8a9e2830.async.js +1 -0
  47. package/static/dist/4674.0196afcf.async.js +1 -0
  48. package/static/dist/4714.4abfa66f.async.js +1 -0
  49. package/static/dist/4906.493cf3fd.async.js +1 -0
  50. package/static/dist/4925.9e8a41a2.async.js +1 -0
  51. package/static/dist/5310.213fe20f.async.js +1 -0
  52. package/static/dist/5394.de174420.async.js +1 -0
  53. package/static/dist/5484.8b81227f.async.js +1 -0
  54. package/static/dist/{6035.8de00e43.async.js → 6035.48d17c03.async.js} +1 -9
  55. package/static/dist/6064.a5141a7d.async.js +1 -0
  56. package/static/dist/6141.db67ebff.async.js +1 -0
  57. package/static/dist/6433.d9698b6c.async.js +1 -0
  58. package/static/dist/6644.fe01612c.async.js +1 -0
  59. package/static/dist/6747.36513965.async.js +1 -0
  60. package/static/dist/6805.5446eb5a.async.js +1 -0
  61. package/static/dist/6986.57a091e1.async.js +1 -0
  62. package/static/dist/7382.26e7f5a4.async.js +1 -0
  63. package/static/dist/7393.1f1df786.async.js +1 -0
  64. package/static/dist/7708.dc75b315.async.js +1 -0
  65. package/static/dist/7742.863081f5.async.js +1 -0
  66. package/static/dist/7878.91f5096f.async.js +1 -0
  67. package/static/dist/8037.dd53e9c8.async.js +1 -0
  68. package/static/dist/8044.b4f59bd9.async.js +1 -0
  69. package/static/dist/8130.10d10b7d.async.js +1 -0
  70. package/static/dist/8167.8f9d5e88.async.js +1 -0
  71. package/static/dist/819.ea86849f.async.js +1 -0
  72. package/static/dist/827.efeeec44.async.js +1 -0
  73. package/static/dist/8297.c44afb18.async.js +1 -0
  74. package/static/dist/8432.055570e6.async.js +1 -0
  75. package/static/dist/858.1899883e.async.js +1 -0
  76. package/static/dist/8605.f56664b9.async.js +1 -0
  77. package/static/dist/8969.26b0efff.async.js +1 -0
  78. package/static/dist/9065.8be8d60f.async.js +1 -0
  79. package/static/dist/9504.248f6493.async.js +1 -0
  80. package/static/dist/9532.af314989.async.js +1 -0
  81. package/static/dist/9673.5576fcd4.async.js +1 -0
  82. package/static/dist/9692.e04f774e.async.js +1 -0
  83. package/static/dist/index.html +1 -1
  84. package/static/dist/layouts__index.20e4a8b2.async.js +1 -0
  85. package/static/dist/layouts__index.dc3fe99d.chunk.css +1 -0
  86. package/static/dist/src__pages__404.f77cf9a2.async.js +1 -0
  87. package/static/dist/src__pages__config__index.34473d74.async.js +1 -0
  88. package/static/dist/src__pages__crontab__detail.91b2b006.async.js +1 -0
  89. package/static/dist/{src__pages__crontab__index.ea0ad17d.chunk.css → src__pages__crontab__index.502a1f71.chunk.css} +1 -1
  90. package/static/dist/src__pages__crontab__index.7443956f.async.js +1 -0
  91. package/static/dist/src__pages__crontab__logModal.a0c9c75c.async.js +1 -0
  92. package/static/dist/src__pages__crontab__modal.e43fadf0.async.js +1 -0
  93. package/static/dist/src__pages__crontab__type.bd5374bd.async.js +1 -0
  94. package/static/dist/src__pages__crontab__viewCreateModal.c46df55e.async.js +1 -0
  95. package/static/dist/src__pages__crontab__viewManageModal.1bb04623.async.js +1 -0
  96. package/static/dist/src__pages__dependence__index.29219078.async.js +1 -0
  97. package/static/dist/src__pages__dependence__logModal.8eb8ba1b.async.js +1 -0
  98. package/static/dist/src__pages__dependence__modal.0e940eb0.async.js +1 -0
  99. package/static/dist/src__pages__diff__index.630603fc.async.js +1 -0
  100. package/static/dist/src__pages__env__editNameModal.a1f5c3e1.async.js +1 -0
  101. package/static/dist/src__pages__env__index.03e934be.async.js +1 -0
  102. package/static/dist/src__pages__env__modal.c44800ec.async.js +1 -0
  103. package/static/dist/src__pages__error__index.521fde97.async.js +1 -0
  104. package/static/dist/src__pages__initialization__index.0e4d45ef.async.js +1 -0
  105. package/static/dist/src__pages__log__index.8da82aea.async.js +1 -0
  106. package/static/dist/src__pages__login__index.ce467c16.async.js +1 -0
  107. package/static/dist/src__pages__script__editModal.7bec90a6.async.js +1 -0
  108. package/static/dist/src__pages__script__editNameModal.d2c2b500.async.js +1 -0
  109. package/static/dist/src__pages__script__index.f666bbf7.async.js +1 -0
  110. package/static/dist/src__pages__script__renameModal.03a9a63a.async.js +1 -0
  111. package/static/dist/src__pages__script__saveModal.fe022069.async.js +1 -0
  112. package/static/dist/src__pages__script__setting.25861cb9.async.js +1 -0
  113. package/static/dist/src__pages__setting__about.5343d1cb.async.js +1 -0
  114. package/static/dist/src__pages__setting__appModal.b0f04766.async.js +1 -0
  115. package/static/dist/src__pages__setting__checkUpdate.9901a906.async.js +1 -0
  116. package/static/dist/src__pages__setting__index.6cfb3c67.async.js +1 -0
  117. package/static/dist/src__pages__setting__loginLog.4f883eb7.async.js +1 -0
  118. package/static/dist/src__pages__setting__notification.566573dd.async.js +1 -0
  119. package/static/dist/src__pages__setting__other.5babac76.async.js +1 -0
  120. package/static/dist/src__pages__setting__progress.ab51bf0a.async.js +1 -0
  121. package/static/dist/src__pages__setting__security.ef345c25.async.js +1 -0
  122. package/static/dist/src__pages__subscription__index.373b2030.async.js +1 -0
  123. package/static/dist/src__pages__subscription__logModal.1acd5872.async.js +1 -0
  124. package/static/dist/src__pages__subscription__modal.01b60226.async.js +1 -0
  125. package/static/dist/umi.e6315bf1.js +1 -0
  126. package/version.yaml +9 -11
  127. package/static/dist/1186.fba4581b.async.js +0 -2
  128. package/static/dist/1571.68121491.async.js +0 -44
  129. package/static/dist/1925.c5a319f8.async.js +0 -6
  130. package/static/dist/2260.d9fbd460.async.js +0 -1
  131. package/static/dist/2536.f6b15c54.async.js +0 -1
  132. package/static/dist/2618.1484edc2.async.js +0 -2
  133. package/static/dist/2715.80e099e1.async.js +0 -1
  134. package/static/dist/2755.5e73f03b.async.js +0 -11
  135. package/static/dist/29.b629a4b2.async.js +0 -1
  136. package/static/dist/3271.913214bd.async.js +0 -1
  137. package/static/dist/3330.962bc898.async.js +0 -1
  138. package/static/dist/3490.8d2d9399.async.js +0 -24
  139. package/static/dist/3639.58c3a3f1.async.js +0 -5
  140. package/static/dist/3669.4f05548e.async.js +0 -3
  141. package/static/dist/380.8fbf55d6.async.js +0 -1
  142. package/static/dist/3800.34124d62.async.js +0 -2
  143. package/static/dist/4124.8cba8410.async.js +0 -1
  144. package/static/dist/4163.a363bae0.async.js +0 -1
  145. package/static/dist/4424.98b4bd4c.async.js +0 -1
  146. package/static/dist/4674.403f1511.async.js +0 -1
  147. package/static/dist/4714.6f75a879.async.js +0 -4
  148. package/static/dist/4906.119e3e0f.async.js +0 -81
  149. package/static/dist/4925.eca85085.async.js +0 -1
  150. package/static/dist/5310.6c4eff46.async.js +0 -1
  151. package/static/dist/5484.826c5ee3.async.js +0 -1
  152. package/static/dist/6329.c3cd1754.async.js +0 -26
  153. package/static/dist/6433.69941426.async.js +0 -22
  154. package/static/dist/6644.5df1dec2.async.js +0 -62
  155. package/static/dist/6661.5cda5ce0.async.js +0 -1
  156. package/static/dist/6805.798ec30a.async.js +0 -1
  157. package/static/dist/6986.6960fa24.async.js +0 -1
  158. package/static/dist/7382.305c10b2.async.js +0 -27
  159. package/static/dist/7393.86229389.async.js +0 -1
  160. package/static/dist/7708.b1e590e4.async.js +0 -1
  161. package/static/dist/7742.dd8a0112.async.js +0 -12
  162. package/static/dist/8037.386b415d.async.js +0 -1
  163. package/static/dist/8044.06e91ce9.async.js +0 -18
  164. package/static/dist/8130.97ce9ff6.async.js +0 -4
  165. package/static/dist/819.c1b8de99.async.js +0 -4
  166. package/static/dist/8297.e6ac1ce9.async.js +0 -1
  167. package/static/dist/8432.5bbc2cdd.async.js +0 -1
  168. package/static/dist/858.d51fc4e2.async.js +0 -1
  169. package/static/dist/8969.2ad6c360.async.js +0 -1
  170. package/static/dist/9065.6684b5d0.async.js +0 -1
  171. package/static/dist/9504.6d4e29e7.async.js +0 -1
  172. package/static/dist/9532.a47c2a0e.async.js +0 -1
  173. package/static/dist/9673.6cf1fa68.async.js +0 -3
  174. package/static/dist/9692.aca6cd4e.async.js +0 -4
  175. package/static/dist/layouts__index.47395c48.chunk.css +0 -1
  176. package/static/dist/layouts__index.f45c1c77.async.js +0 -1
  177. package/static/dist/src__pages__404.da927616.async.js +0 -1
  178. package/static/dist/src__pages__config__index.638ee578.async.js +0 -22
  179. package/static/dist/src__pages__crontab__detail.c9ee5de3.async.js +0 -2
  180. package/static/dist/src__pages__crontab__index.f6a24b58.async.js +0 -19
  181. package/static/dist/src__pages__crontab__logModal.c630dc95.async.js +0 -1
  182. package/static/dist/src__pages__crontab__modal.c94bad49.async.js +0 -4
  183. package/static/dist/src__pages__crontab__type.136454fe.async.js +0 -1
  184. package/static/dist/src__pages__crontab__viewCreateModal.090fb218.async.js +0 -1
  185. package/static/dist/src__pages__crontab__viewManageModal.f79bdbdd.async.js +0 -1
  186. package/static/dist/src__pages__dependence__index.288f8cb2.async.js +0 -2
  187. package/static/dist/src__pages__dependence__logModal.80ff90bc.async.js +0 -4
  188. package/static/dist/src__pages__dependence__modal.8c434892.async.js +0 -5
  189. package/static/dist/src__pages__diff__index.9bff5d4a.async.js +0 -5
  190. package/static/dist/src__pages__env__editNameModal.7e592361.async.js +0 -4
  191. package/static/dist/src__pages__env__index.b9a18b25.async.js +0 -2
  192. package/static/dist/src__pages__env__modal.12d3d833.async.js +0 -5
  193. package/static/dist/src__pages__error__index.b3c10262.async.js +0 -4
  194. package/static/dist/src__pages__initialization__index.4e7bbbb9.async.js +0 -21
  195. package/static/dist/src__pages__log__index.fe97493d.async.js +0 -1
  196. package/static/dist/src__pages__login__index.7f920198.async.js +0 -1
  197. package/static/dist/src__pages__script__editModal.2a16e662.async.js +0 -4
  198. package/static/dist/src__pages__script__editNameModal.a3391e87.async.js +0 -4
  199. package/static/dist/src__pages__script__index.b772364f.async.js +0 -6
  200. package/static/dist/src__pages__script__renameModal.2bf73e46.async.js +0 -4
  201. package/static/dist/src__pages__script__saveModal.422f1cd7.async.js +0 -4
  202. package/static/dist/src__pages__script__setting.2b76ab6a.async.js +0 -4
  203. package/static/dist/src__pages__setting__about.c3cdad66.async.js +0 -1
  204. package/static/dist/src__pages__setting__appModal.b85e6aeb.async.js +0 -4
  205. package/static/dist/src__pages__setting__checkUpdate.e8512ada.async.js +0 -1
  206. package/static/dist/src__pages__setting__index.baad795d.async.js +0 -1
  207. package/static/dist/src__pages__setting__loginLog.e74c10b2.async.js +0 -18
  208. package/static/dist/src__pages__setting__notification.af705cea.async.js +0 -21
  209. package/static/dist/src__pages__setting__other.e735251a.async.js +0 -1
  210. package/static/dist/src__pages__setting__progress.bd2dfeee.async.js +0 -1
  211. package/static/dist/src__pages__setting__security.b65e9b12.async.js +0 -4
  212. package/static/dist/src__pages__subscription__index.682c6e4b.async.js +0 -1
  213. package/static/dist/src__pages__subscription__logModal.c1a59322.async.js +0 -1
  214. package/static/dist/src__pages__subscription__modal.7cdfec68.async.js +0 -4
  215. package/static/dist/umi.a24c0389.js +0 -105
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
@@ -112,6 +112,7 @@
112
112
  "typedi": "^0.10.0",
113
113
  "uuid": "^8.3.2",
114
114
  "winston": "^3.6.0",
115
+ "winston-daily-rotate-file": "^4.7.1",
115
116
  "yargs": "^17.3.1"
116
117
  },
117
118
  "devDependencies": {
@@ -143,6 +144,8 @@
143
144
  "@types/sockjs-client": "^1.5.1",
144
145
  "@types/tar": "^6.1.5",
145
146
  "@types/uuid": "^8.3.4",
147
+ "@uiw/codemirror-extensions-langs": "^4.21.9",
148
+ "@uiw/react-codemirror": "^4.21.9",
146
149
  "@umijs/max": "^4.0.72",
147
150
  "@umijs/ssr-darkreader": "^4.9.45",
148
151
  "ahooks": "^3.7.8",
@@ -150,7 +153,6 @@
150
153
  "antd": "^4.24.8",
151
154
  "antd-img-crop": "^4.2.3",
152
155
  "axios": "^1.4.0",
153
- "codemirror": "^5.65.2",
154
156
  "compression-webpack-plugin": "9.2.0",
155
157
  "concurrently": "^7.0.0",
156
158
  "file-saver": "^2.0.5",
@@ -164,7 +166,6 @@
164
166
  "rc-tween-one": "^3.0.6",
165
167
  "rc-virtual-list": "3.5.3",
166
168
  "react": "18.2.0",
167
- "react-codemirror2": "^7.2.1",
168
169
  "react-copy-to-clipboard": "^5.1.0",
169
170
  "react-diff-viewer": "^3.1.1",
170
171
  "react-dnd": "^14.0.2",
package/sample/notify.py CHANGED
@@ -456,7 +456,7 @@ class WeCom:
456
456
  return respone["errmsg"]
457
457
 
458
458
  def send_mpnews(self, title, message, media_id, touser="@all"):
459
- send_url = f"https://{self.HOST}/cgi-bin/message/send?access_token={self.get_access_token()}"
459
+ send_url = f"https://{self.ORIGIN}/cgi-bin/message/send?access_token={self.get_access_token()}"
460
460
  send_values = {
461
461
  "touser": touser,
462
462
  "msgtype": "mpnews",
package/shell/share.sh CHANGED
@@ -301,7 +301,7 @@ git_clone_scripts() {
301
301
 
302
302
  set_proxy "$proxy"
303
303
 
304
- git clone --depth=1 $part_cmd $url $dir
304
+ git clone --depth=1 $part_cmd $url $dir 2>&1
305
305
  exit_status=$?
306
306
 
307
307
  unset_proxy
@@ -225,5 +225,14 @@ exports.default = (app) => {
225
225
  return next(e);
226
226
  }
227
227
  });
228
+ route.get('/log', async (req, res, next) => {
229
+ try {
230
+ const systemService = typedi_1.Container.get(system_1.default);
231
+ await systemService.getSystemLog(res);
232
+ }
233
+ catch (e) {
234
+ return next(e);
235
+ }
236
+ });
228
237
  };
229
238
  //# sourceMappingURL=system.js.map
@@ -17,10 +17,12 @@ async function startServer() {
17
17
  .listen(config_1.default.port, () => {
18
18
  var _a;
19
19
  logger_1.default.debug(`✌️ 后端服务启动成功!`);
20
+ console.debug(`✌️ 后端服务启动成功!`);
20
21
  (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
21
22
  })
22
23
  .on('error', (err) => {
23
24
  logger_1.default.error(err);
25
+ console.error(err);
24
26
  process.exit(1);
25
27
  });
26
28
  await require('./loaders/server').default({ server });
@@ -33,6 +33,7 @@ const logPath = path_1.default.join(dataPath, 'log/');
33
33
  const dbPath = path_1.default.join(dataPath, 'db/');
34
34
  const uploadPath = path_1.default.join(dataPath, 'upload/');
35
35
  const sshdPath = path_1.default.join(dataPath, 'ssh.d/');
36
+ const systemLogPath = path_1.default.join(dataPath, 'syslog/');
36
37
  const envFile = path_1.default.join(configPath, 'env.sh');
37
38
  const confFile = path_1.default.join(configPath, 'config.sh');
38
39
  const crontabFile = path_1.default.join(configPath, 'crontab.list');
@@ -109,5 +110,6 @@ exports.default = {
109
110
  lastVersionFile,
110
111
  sqliteFile,
111
112
  sshdPath,
113
+ systemLogPath,
112
114
  };
113
115
  //# sourceMappingURL=index.js.map
@@ -312,10 +312,15 @@ var FileType;
312
312
  FileType[FileType["file"] = 1] = "file";
313
313
  })(FileType || (FileType = {}));
314
314
  function dirSort(a, b) {
315
- if (a.type !== b.type)
315
+ if (a.type !== b.type) {
316
316
  return FileType[a.type] < FileType[b.type] ? -1 : 1;
317
- else if (a.mtime !== b.mtime)
317
+ }
318
+ else if (a.mtime !== b.mtime) {
318
319
  return a.mtime > b.mtime ? -1 : 1;
320
+ }
321
+ else {
322
+ return 0;
323
+ }
319
324
  }
320
325
  exports.dirSort = dirSort;
321
326
  function readDirs(dir, baseDir = '', blacklist = []) {
@@ -343,6 +348,7 @@ function readDirs(dir, baseDir = '', blacklist = []) {
343
348
  isLeaf: true,
344
349
  key,
345
350
  parent: relativePath,
351
+ size: stats.size,
346
352
  mtime: stats.mtime.getTime(),
347
353
  };
348
354
  });
@@ -10,15 +10,26 @@ const initData_1 = __importDefault(require("./initData"));
10
10
  const deps_1 = __importDefault(require("./deps"));
11
11
  const initTask_1 = __importDefault(require("./initTask"));
12
12
  exports.default = async ({ expressApp }) => {
13
- await (0, depInjector_1.default)();
14
- logger_1.default.info('✌️ Dependency Injector loaded');
15
- await (0, express_1.default)({ app: expressApp });
16
- logger_1.default.info('✌️ Express loaded');
17
- await (0, initData_1.default)();
18
- logger_1.default.info('✌️ init data loaded');
19
- await (0, deps_1.default)();
20
- logger_1.default.info('✌️ link deps loaded');
21
- (0, initTask_1.default)();
22
- logger_1.default.info('✌️ init task loaded');
13
+ try {
14
+ (0, depInjector_1.default)();
15
+ logger_1.default.info('✌️ Dependency Injector loaded');
16
+ console.log('✌️ Dependency Injector loaded');
17
+ (0, express_1.default)({ app: expressApp });
18
+ logger_1.default.info('✌️ Express loaded');
19
+ console.log('✌️ Express loaded');
20
+ await (0, initData_1.default)();
21
+ logger_1.default.info('✌️ init data loaded');
22
+ console.log('✌️ init data loaded');
23
+ await (0, deps_1.default)();
24
+ logger_1.default.info('✌️ link deps loaded');
25
+ console.log('✌️ link deps loaded');
26
+ (0, initTask_1.default)();
27
+ logger_1.default.info('✌️ init task loaded');
28
+ console.log('✌️ init task loaded');
29
+ }
30
+ catch (error) {
31
+ logger_1.default.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed, ${error}`);
32
+ console.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed ${error}`);
33
+ }
23
34
  };
24
35
  //# sourceMappingURL=app.js.map
@@ -116,11 +116,12 @@ exports.default = async () => {
116
116
  await auth_1.AuthModel.bulkCreate(docs, { ignoreDuplicates: true });
117
117
  });
118
118
  }
119
+ console.log('✌️ DB loaded');
119
120
  logger_1.default.info('✌️ DB loaded');
120
121
  }
121
122
  catch (error) {
122
- logger_1.default.info('✌️ DB load failed');
123
- logger_1.default.info(error);
123
+ console.error('✌️ DB load failed');
124
+ logger_1.default.error(error);
124
125
  }
125
126
  };
126
127
  //# sourceMappingURL=db.js.map
@@ -43,6 +43,7 @@ const env_1 = require("../data/env");
43
43
  const celebrate_1 = require("celebrate");
44
44
  const http_proxy_middleware_1 = require("http-proxy-middleware");
45
45
  const serverEnv_1 = require("../config/serverEnv");
46
+ const logger_1 = __importDefault(require("./logger"));
46
47
  exports.default = ({ app }) => {
47
48
  app.enable('trust proxy');
48
49
  app.use((0, cors_1.default)());
@@ -52,6 +53,7 @@ exports.default = ({ app }) => {
52
53
  target: `http://localhost:${config_1.default.publicPort}/api`,
53
54
  changeOrigin: true,
54
55
  pathRewrite: { '/api/public': '' },
56
+ logProvider: () => logger_1.default
55
57
  }));
56
58
  app.use(body_parser_1.default.json({ limit: '50mb' }));
57
59
  app.use(body_parser_1.default.urlencoded({ limit: '50mb', extended: true }));
@@ -35,6 +35,7 @@ const TaskAfterFile = path_1.default.join(configPath, 'task_after.sh');
35
35
  const homedir = os_1.default.homedir();
36
36
  const sshPath = path_1.default.resolve(homedir, '.ssh');
37
37
  const sshdPath = path_1.default.join(dataPath, 'ssh.d');
38
+ const systemLogPath = path_1.default.join(dataPath, 'syslog');
38
39
  exports.default = async () => {
39
40
  const authFileExist = await (0, util_1.fileExist)(authConfigFile);
40
41
  const confFileExist = await (0, util_1.fileExist)(confFile);
@@ -45,6 +46,7 @@ exports.default = async () => {
45
46
  const sshDirExist = await (0, util_1.fileExist)(sshPath);
46
47
  const bakDirExist = await (0, util_1.fileExist)(bakPath);
47
48
  const sshdDirExist = await (0, util_1.fileExist)(sshdPath);
49
+ const systemLogDirExist = await (0, util_1.fileExist)(systemLogPath);
48
50
  const tmpDirExist = await (0, util_1.fileExist)(tmpPath);
49
51
  const scriptNotifyJsFileExist = await (0, util_1.fileExist)(scriptNotifyJsFile);
50
52
  const scriptNotifyPyFileExist = await (0, util_1.fileExist)(scriptNotifyPyFile);
@@ -74,6 +76,9 @@ exports.default = async () => {
74
76
  if (!sshdDirExist) {
75
77
  fs_1.default.mkdirSync(sshdPath);
76
78
  }
79
+ if (!systemLogDirExist) {
80
+ fs_1.default.mkdirSync(systemLogPath);
81
+ }
77
82
  // 初始化文件
78
83
  if (!authFileExist) {
79
84
  fs_1.default.writeFileSync(authConfigFile, fs_1.default.readFileSync(sampleAuthFile));
@@ -95,5 +100,6 @@ exports.default = async () => {
95
100
  }
96
101
  dotenv_1.default.config({ path: confFile });
97
102
  logger_1.default.info('✌️ Init file down');
103
+ console.log('✌️ Init file down');
98
104
  };
99
105
  //# sourceMappingURL=initFile.js.map
@@ -4,23 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const winston_1 = __importDefault(require("winston"));
7
+ require("winston-daily-rotate-file");
7
8
  const config_1 = __importDefault(require("../config"));
8
- const transports = [];
9
- if (process.env.NODE_ENV !== 'development') {
10
- transports.push(new winston_1.default.transports.Console());
11
- }
12
- else {
13
- transports.push(new winston_1.default.transports.Console({
14
- format: winston_1.default.format.combine(winston_1.default.format.cli(), winston_1.default.format.splat()),
15
- }));
16
- }
9
+ const path_1 = __importDefault(require("path"));
10
+ const levelMap = {
11
+ info: '🔵',
12
+ warn: '🟡',
13
+ error: '🔴',
14
+ debug: '🔶'
15
+ };
16
+ const customFormat = winston_1.default.format.combine(winston_1.default.format.splat(), winston_1.default.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston_1.default.format.align(), winston_1.default.format.printf((i) => `[${levelMap[i.level]}${i.level}] [${[i.timestamp]}]: ${i.message}`));
17
+ const defaultOptions = {
18
+ format: customFormat,
19
+ datePattern: "YYYY-MM-DD",
20
+ maxSize: "20m",
21
+ maxFiles: "7d",
22
+ };
17
23
  const LoggerInstance = winston_1.default.createLogger({
18
24
  level: config_1.default.logs.level,
19
25
  levels: winston_1.default.config.npm.levels,
20
- format: winston_1.default.format.combine(winston_1.default.format.timestamp({
21
- format: 'YYYY-MM-DD HH:mm:ss',
22
- }), winston_1.default.format.errors({ stack: true }), winston_1.default.format.splat(), winston_1.default.format.json()),
23
- transports,
26
+ transports: [
27
+ new winston_1.default.transports.DailyRotateFile(Object.assign({ filename: path_1.default.join(config_1.default.systemLogPath, '%DATE%.log') }, defaultOptions))
28
+ ],
24
29
  });
25
30
  exports.default = LoggerInstance;
26
31
  //# sourceMappingURL=logger.js.map
@@ -51,5 +51,6 @@ exports.default = async ({ expressApp }) => {
51
51
  expressApp.use(Sentry.Handlers.requestHandler());
52
52
  expressApp.use(Sentry.Handlers.tracingHandler());
53
53
  logger_1.default.info('✌️ Sentry loaded');
54
+ console.log('✌️ Sentry loaded');
54
55
  };
55
56
  //# sourceMappingURL=sentry.js.map
@@ -12,9 +12,11 @@ exports.default = async ({ server }) => {
12
12
  let timer;
13
13
  process.on('SIGINT', (singal) => {
14
14
  logger_1.default.warn(`Server need close, singal ${singal}`);
15
+ console.warn(`Server need close, singal ${singal}`);
15
16
  exitTime++;
16
17
  if (exitTime >= 3) {
17
18
  logger_1.default.warn('Forcing server close');
19
+ console.warn('Forcing server close');
18
20
  clearTimeout(timer);
19
21
  process.exit(1);
20
22
  }
@@ -29,10 +31,12 @@ exports.default = async ({ server }) => {
29
31
  });
30
32
  process.on('uncaughtException', (error) => {
31
33
  logger_1.default.error('Uncaught exception:', error);
34
+ console.error('Uncaught exception:', error);
32
35
  process.exit(1);
33
36
  });
34
37
  process.on('unhandledRejection', (reason, promise) => {
35
- logger_1.default.error('Unhandled rejection:', reason);
38
+ logger_1.default.error('Unhandled rejection:', reason, promise);
39
+ console.error('Unhandled rejection:', reason, promise);
36
40
  process.exit(1);
37
41
  });
38
42
  };
@@ -9,7 +9,7 @@ const config_1 = __importDefault(require("./config"));
9
9
  const health_1 = require("./protos/health");
10
10
  const grpc_js_1 = require("@grpc/grpc-js");
11
11
  const app = (0, express_1.default)();
12
- const client = new health_1.HealthClient(`localhost:${config_1.default.cronPort}`, grpc_js_1.credentials.createInsecure());
12
+ const client = new health_1.HealthClient(`0.0.0.0:${config_1.default.cronPort}`, grpc_js_1.credentials.createInsecure());
13
13
  app.get('/api/health', (req, res) => {
14
14
  client.check({ service: 'cron' }, (err, response) => {
15
15
  if (err) {
@@ -24,10 +24,12 @@ app
24
24
  await require('./loaders/sentry').default({ expressApp: app });
25
25
  await require('./loaders/db').default();
26
26
  logger_1.default.debug(`✌️ 公共服务启动成功!`);
27
+ console.debug(`✌️ 公共服务启动成功!`);
27
28
  (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
28
29
  })
29
30
  .on('error', (err) => {
30
31
  logger_1.default.error(err);
32
+ console.error(err);
31
33
  process.exit(1);
32
34
  });
33
35
  //# sourceMappingURL=public.js.map
@@ -21,8 +21,9 @@ const addCron = (call, callback) => {
21
21
  if (!cmdStr.startsWith(const_1.TASK_PREFIX) && !cmdStr.startsWith(const_1.QL_PREFIX)) {
22
22
  cmdStr = `${const_1.TASK_PREFIX}${cmdStr}`;
23
23
  }
24
+ logger_1.default.info('[schedule][创建定时任务], 任务ID: %s, cron: %s, 执行命令: %s', id, schedule, command);
24
25
  data_1.scheduleStacks.set(id, node_schedule_1.default.scheduleJob(id, schedule, async () => {
25
- logger_1.default.info(`当前时间: ${(0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss')},运行命令: ${cmdStr}`);
26
+ logger_1.default.info(`[schedule] 时间: ${(0, dayjs_1.default)().format('YYYY-MM-DD HH:mm:ss')},运行命令: ${cmdStr}`);
26
27
  (0, runCron_1.runCron)(`ID=${id} ${cmdStr}`);
27
28
  }));
28
29
  }
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.delCron = void 0;
4
7
  const data_1 = require("./data");
8
+ const logger_1 = __importDefault(require("../loaders/logger"));
5
9
  const delCron = (call, callback) => {
6
10
  var _a;
7
11
  for (const id of call.request.ids) {
8
12
  if (data_1.scheduleStacks.has(id)) {
13
+ logger_1.default.info('[schedule][取消定时任务], 任务ID: %s', id);
9
14
  (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.cancel();
10
15
  data_1.scheduleStacks.delete(id);
11
16
  }
@@ -14,13 +14,14 @@ const logger_1 = __importDefault(require("../loaders/logger"));
14
14
  const server = new grpc_js_1.Server();
15
15
  server.addService(health_1.HealthService, { check: health_2.check });
16
16
  server.addService(cron_1.CronService, { addCron: addCron_1.addCron, delCron: delCron_1.delCron });
17
- server.bindAsync(`localhost:${config_1.default.cronPort}`, grpc_js_1.ServerCredentials.createInsecure(), (err, port) => {
17
+ server.bindAsync(`0.0.0.0:${config_1.default.cronPort}`, grpc_js_1.ServerCredentials.createInsecure(), (err, port) => {
18
18
  var _a;
19
19
  if (err) {
20
20
  throw err;
21
21
  }
22
22
  server.start();
23
23
  logger_1.default.debug(`✌️ 定时服务启动成功!`);
24
+ console.debug(`✌️ 定时服务启动成功!`);
24
25
  (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
25
26
  });
26
27
  //# sourceMappingURL=index.js.map
@@ -139,7 +139,7 @@ let CronService = class CronService {
139
139
  case 'In':
140
140
  q[sequelize_1.Op.or] = [
141
141
  {
142
- [property]: value,
142
+ [property]: Array.isArray(value) ? value : [value],
143
143
  },
144
144
  property === 'status' && value.includes(2)
145
145
  ? { isDisabled: 1 }
@@ -150,7 +150,7 @@ let CronService = class CronService {
150
150
  q[sequelize_1.Op.and] = [
151
151
  {
152
152
  [property]: {
153
- [sequelize_1.Op.notIn]: value,
153
+ [sequelize_1.Op.notIn]: Array.isArray(value) ? value : [value],
154
154
  },
155
155
  },
156
156
  property === 'status' && value.includes(2)
@@ -329,7 +329,7 @@ let CronService = class CronService {
329
329
  await (0, util_1.killTask)(doc.pid);
330
330
  }
331
331
  catch (error) {
332
- this.logger.silly(error);
332
+ this.logger.error(error);
333
333
  }
334
334
  }
335
335
  }
@@ -460,7 +460,6 @@ let CronService = class CronService {
460
460
  crontab_string += '\n';
461
461
  }
462
462
  });
463
- this.logger.silly(crontab_string);
464
463
  fs_1.default.writeFileSync(config_1.default.crontabFile, crontab_string);
465
464
  await cron_1.CrontabModel.update({ saved: true }, { where: {} });
466
465
  }
@@ -175,7 +175,7 @@ let DependenceService = class DependenceService {
175
175
  if (depInfo &&
176
176
  ((isNodeDependence && ((_a = depInfo.split(' ')) === null || _a === void 0 ? void 0 : _a[0]) === depName) ||
177
177
  (isLinuxDependence &&
178
- depInfo.toLocaleLowerCase().includes('installed')) ||
178
+ depInfo.toLocaleLowerCase().includes('apt-manual-installed')) ||
179
179
  isPythonDependence) &&
180
180
  (!depVersion || depInfo.includes(depVersion))) {
181
181
  const endTime = (0, dayjs_1.default)();
@@ -45,16 +45,16 @@ let ScheduleService = class ScheduleService {
45
45
  });
46
46
  cp.stderr.on('data', async (data) => {
47
47
  var _a;
48
- this.logger.info('[执行任务失败] %s,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), data.toString());
48
+ this.logger.info('[执行任务失败] %s, 时间: %s, 错误信息: %j', command, new Date().toLocaleString(), data.toString());
49
49
  await ((_a = callbacks.onError) === null || _a === void 0 ? void 0 : _a.call(callbacks, data.toString()));
50
50
  });
51
51
  cp.on('error', async (err) => {
52
52
  var _a;
53
- this.logger.error('[创建任务失败] %s,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), err);
53
+ this.logger.error('[创建任务失败] %s, 时间: %s, 错误信息: %j', command, new Date().toLocaleString(), err);
54
54
  await ((_a = callbacks.onError) === null || _a === void 0 ? void 0 : _a.call(callbacks, JSON.stringify(err)));
55
55
  });
56
56
  cp.on('exit', async (code, signal) => {
57
- this.logger.info(`[任务退出] ${command} 进程id: ${cp.pid},退出码 ${code}`);
57
+ this.logger.info(`[任务退出] ${command} 进程id: ${cp.pid}, 退出码 ${code}`);
58
58
  });
59
59
  cp.on('close', async (code) => {
60
60
  var _a;
@@ -64,7 +64,7 @@ let ScheduleService = class ScheduleService {
64
64
  });
65
65
  }
66
66
  catch (error) {
67
- await this.logger.error('执行任务%s失败,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), error);
67
+ await this.logger.error('[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j', command, new Date().toLocaleString(), error);
68
68
  await ((_c = callbacks.onError) === null || _c === void 0 ? void 0 : _c.call(callbacks, JSON.stringify(error)));
69
69
  }
70
70
  });
@@ -72,7 +72,7 @@ let ScheduleService = class ScheduleService {
72
72
  }
73
73
  async createCronTask({ id = 0, command, name, schedule = '' }, callbacks, runImmediately = false) {
74
74
  const _id = this.formatId(id);
75
- this.logger.info('[创建cron任务],任务ID: %scron: %s,任务名: %s,执行命令: %s', _id, schedule, name, command);
75
+ this.logger.info('[创建cron任务], 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s', _id, schedule, name, command);
76
76
  this.scheduleStacks.set(_id, node_schedule_1.default.scheduleJob(_id, schedule, async () => {
77
77
  this.runTask(command, callbacks);
78
78
  }));
@@ -83,7 +83,7 @@ let ScheduleService = class ScheduleService {
83
83
  async cancelCronTask({ id = 0, name }) {
84
84
  var _a;
85
85
  const _id = this.formatId(id);
86
- this.logger.info('[取消定时任务],任务名:%s', name);
86
+ this.logger.info('[取消定时任务], 任务名: %s', name);
87
87
  if (this.scheduleStacks.has(_id)) {
88
88
  (_a = this.scheduleStacks.get(_id)) === null || _a === void 0 ? void 0 : _a.cancel();
89
89
  this.scheduleStacks.delete(_id);
@@ -91,11 +91,11 @@ let ScheduleService = class ScheduleService {
91
91
  }
92
92
  async createIntervalTask({ id = 0, command, name = '' }, schedule, runImmediately = true, callbacks) {
93
93
  const _id = this.formatId(id);
94
- this.logger.info('[创建interval任务],任务ID: %s,任务名: %s,执行命令: %s', _id, name, command);
94
+ this.logger.info('[创建interval任务], 任务ID: %s, 任务名: %s, 执行命令: %s', _id, name, command);
95
95
  const task = new toad_scheduler_1.Task(name, () => {
96
96
  this.runTask(command, callbacks);
97
97
  }, (err) => {
98
- this.logger.error('执行任务%s失败,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), err);
98
+ this.logger.error('[执行任务失败] 命令: %s, 时间: %s, 错误信息: %j', command, new Date().toLocaleString(), err);
99
99
  });
100
100
  const job = new toad_scheduler_1.LongIntervalJob(Object.assign({ runImmediately: false }, schedule), task, _id);
101
101
  this.intervalSchedule.addIntervalJob(job);
@@ -105,7 +105,7 @@ let ScheduleService = class ScheduleService {
105
105
  }
106
106
  async cancelIntervalTask({ id = 0, name }) {
107
107
  const _id = this.formatId(id);
108
- this.logger.info('[取消interval任务],任务ID: %s,任务名:%s', _id, name);
108
+ this.logger.info('[取消interval任务], 任务ID: %s, 任务名: %s', _id, name);
109
109
  this.intervalSchedule.removeById(_id);
110
110
  }
111
111
  formatId(id) {
@@ -255,7 +255,7 @@ let SubscriptionService = class SubscriptionService {
255
255
  await (0, util_1.killTask)(doc.pid);
256
256
  }
257
257
  catch (error) {
258
- this.logger.silly(error);
258
+ this.logger.error(error);
259
259
  }
260
260
  }
261
261
  const absolutePath = await (0, util_1.handleLogPath)(doc.log_path);
@@ -29,6 +29,8 @@ const const_1 = require("../config/const");
29
29
  const pLimit_1 = __importDefault(require("../shared/pLimit"));
30
30
  const tar_1 = __importDefault(require("tar"));
31
31
  const path_1 = __importDefault(require("path"));
32
+ const fs_1 = __importDefault(require("fs"));
33
+ const lodash_1 = require("lodash");
32
34
  let SystemService = class SystemService {
33
35
  constructor(logger, scheduleService, sockService) {
34
36
  this.logger = logger;
@@ -228,6 +230,27 @@ let SystemService = class SystemService {
228
230
  return { code: 400, message: error.message };
229
231
  }
230
232
  }
233
+ async getSystemLog(res) {
234
+ const result = (0, util_1.readDirs)(config_1.default.systemLogPath, config_1.default.systemLogPath);
235
+ const logs = result.reverse().filter((x) => x.title.endsWith('.log'));
236
+ res.set({
237
+ 'Content-Length': (0, lodash_1.sum)(logs.map((x) => x.size)),
238
+ });
239
+ (function sendFiles(res, fileNames) {
240
+ if (fileNames.length === 0) {
241
+ res.end();
242
+ return;
243
+ }
244
+ const currentLog = fileNames.shift();
245
+ if (currentLog) {
246
+ const currentFileStream = fs_1.default.createReadStream(path_1.default.join(config_1.default.systemLogPath, currentLog.title));
247
+ currentFileStream.on('end', () => {
248
+ sendFiles(res, fileNames);
249
+ });
250
+ currentFileStream.pipe(res, { end: false });
251
+ }
252
+ })(res, logs);
253
+ }
231
254
  };
232
255
  __decorate([
233
256
  (0, typedi_1.Inject)((type) => notify_1.default),
@@ -10,16 +10,16 @@ const logger_1 = __importDefault(require("../loaders/logger"));
10
10
  function runCron(cmd) {
11
11
  return pLimit_1.default.runWithCpuLimit(() => {
12
12
  return new Promise(async (resolve) => {
13
- logger_1.default.silly('运行命令: ' + cmd);
13
+ logger_1.default.info(`[schedule][开始执行任务] 运行命令: ${cmd}`);
14
14
  const cp = (0, cross_spawn_1.spawn)(cmd, { shell: '/bin/bash' });
15
15
  cp.stderr.on('data', (data) => {
16
- logger_1.default.info('[执行任务失败] %s,时间:%s, 错误信息:%j', cmd, new Date().toLocaleString(), data.toString());
16
+ logger_1.default.info('[schedule][执行任务失败] %s, 时间: %s, 错误信息: %j', cmd, new Date().toLocaleString(), data.toString());
17
17
  });
18
18
  cp.on('error', (err) => {
19
- logger_1.default.error('[创建任务失败] %s,时间:%s, 错误信息:%j', cmd, new Date().toLocaleString(), err);
19
+ logger_1.default.error('[schedule][创建任务失败] %s, 时间: %s, 错误信息: %j', cmd, new Date().toLocaleString(), err);
20
20
  });
21
21
  cp.on('close', async (code) => {
22
- logger_1.default.info(`[任务退出] ${cmd} 进程id: ${cp.pid} 退出,退出码 ${code}`);
22
+ logger_1.default.info(`[schedule][任务退出] ${cmd} 进程id: ${cp.pid} 退出, 退出码 ${code}`);
23
23
  resolve();
24
24
  });
25
25
  });