@whyour/qinglong 2.19.2-2 → 2.20.0-1

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 (107) hide show
  1. package/.env.example +1 -2
  2. package/README-en.md +4 -2
  3. package/README.md +4 -2
  4. package/back/protos/api.proto +17 -0
  5. package/docker/310.Dockerfile +23 -6
  6. package/docker/Dockerfile +22 -6
  7. package/docker/docker-entrypoint.sh +27 -14
  8. package/package.json +8 -9
  9. package/sample/notify.js +18 -2
  10. package/sample/notify.py +15 -0
  11. package/sample/ql_sample.js +28 -0
  12. package/shell/api.sh +8 -48
  13. package/shell/check.sh +5 -22
  14. package/shell/preload/client.js +6 -1
  15. package/shell/pub.sh +4 -4
  16. package/shell/share.sh +32 -55
  17. package/shell/task.sh +19 -10
  18. package/shell/update.sh +1 -0
  19. package/static/build/api/dependence.js +7 -1
  20. package/static/build/api/env.js +30 -4
  21. package/static/build/api/script.js +47 -8
  22. package/static/build/api/subscription.js +3 -3
  23. package/static/build/api/system.js +19 -26
  24. package/static/build/api/user.js +2 -1
  25. package/static/build/app.js +96 -18
  26. package/static/build/config/index.js +2 -2
  27. package/static/build/config/util.js +24 -1
  28. package/static/build/data/cron.js +4 -0
  29. package/static/build/data/env.js +3 -1
  30. package/static/build/data/notify.js +1 -0
  31. package/static/build/loaders/db.js +29 -35
  32. package/static/build/loaders/deps.js +22 -5
  33. package/static/build/loaders/express.js +19 -10
  34. package/static/build/loaders/initData.js +25 -1
  35. package/static/build/loaders/initTask.js +6 -0
  36. package/static/build/loaders/sock.js +10 -12
  37. package/static/build/protos/api.js +336 -1
  38. package/static/build/schedule/addCron.js +2 -2
  39. package/static/build/schedule/api.js +100 -1
  40. package/static/build/schedule/delCron.js +1 -1
  41. package/static/build/schedule/health.js +2 -3
  42. package/static/build/services/cron.js +54 -20
  43. package/static/build/services/dependence.js +6 -5
  44. package/static/build/services/env.js +9 -2
  45. package/static/build/services/notify.js +17 -5
  46. package/static/build/services/schedule.js +4 -4
  47. package/static/build/services/sshKey.js +24 -4
  48. package/static/build/services/subscription.js +11 -8
  49. package/static/build/services/system.js +15 -0
  50. package/static/build/services/user.js +83 -4
  51. package/static/build/shared/auth.js +40 -0
  52. package/static/build/shared/logStreamManager.js +104 -0
  53. package/static/build/shared/runCron.js +23 -0
  54. package/static/build/validation/schedule.js +39 -2
  55. package/static/dist/1147.856bb861.async.js +1 -0
  56. package/static/dist/1379.f91563a1.async.js +1 -0
  57. package/static/dist/{2208.3bc521b1.async.js → 2208.7bf7e296.async.js} +1 -1
  58. package/static/dist/3191.da7f3e07.async.js +1 -0
  59. package/static/dist/5691.931f59c5.async.js +1 -0
  60. package/static/dist/7571.4f6240b1.async.js +1 -0
  61. package/static/dist/{8826.3ab4ad84.async.js → 8826.5f289c4d.async.js} +1 -1
  62. package/static/dist/index.html +2 -2
  63. package/static/dist/preload_helper.17d7028f.js +1 -0
  64. package/static/dist/{src__pages__crontab__detail.ee431270.async.js → src__pages__crontab__detail.b07f0c0a.async.js} +1 -1
  65. package/static/dist/src__pages__crontab__index.6b90d8c5.async.js +1 -0
  66. package/static/dist/{src__pages__crontab__logModal.57501983.async.js → src__pages__crontab__logModal.5e6a4bf2.async.js} +1 -1
  67. package/static/dist/src__pages__crontab__modal.2d3d4953.async.js +1 -0
  68. package/static/dist/src__pages__dependence__modal.86604072.async.js +1 -0
  69. package/static/dist/{src__pages__env__editNameModal.665393cd.async.js → src__pages__env__editNameModal.79b7cf83.async.js} +1 -1
  70. package/static/dist/src__pages__env__index.a0a2fece.async.js +1 -0
  71. package/static/dist/{src__pages__env__modal.168498f9.async.js → src__pages__env__modal.b84c1173.async.js} +1 -1
  72. package/static/dist/{src__pages__error__index.d9beeda3.async.js → src__pages__error__index.01fac00e.async.js} +1 -1
  73. package/static/dist/{src__pages__initialization__index.2403c031.async.js → src__pages__initialization__index.2e49cf43.async.js} +1 -1
  74. package/static/dist/{src__pages__script__editNameModal.e36cd111.async.js → src__pages__script__editNameModal.05441c89.async.js} +1 -1
  75. package/static/dist/{src__pages__script__index.82b42e11.async.js → src__pages__script__index.6a23d7b5.async.js} +1 -1
  76. package/static/dist/{src__pages__script__renameModal.f9756f26.async.js → src__pages__script__renameModal.3bb00014.async.js} +1 -1
  77. package/static/dist/{src__pages__script__saveModal.e885e133.async.js → src__pages__script__saveModal.03cc698b.async.js} +1 -1
  78. package/static/dist/{src__pages__script__setting.8c2727b4.async.js → src__pages__script__setting.5a2a2a2c.async.js} +1 -1
  79. package/static/dist/{src__pages__setting__appModal.5a39121e.async.js → src__pages__setting__appModal.7f763fa7.async.js} +1 -1
  80. package/static/dist/src__pages__setting__dependence.e64c4554.async.js +1 -0
  81. package/static/dist/src__pages__setting__index.3a220288.async.js +1 -0
  82. package/static/dist/src__pages__setting__notification.49003b2f.async.js +1 -0
  83. package/static/dist/src__pages__setting__other.0d931d6f.async.js +1 -0
  84. package/static/dist/src__pages__setting__security.a916e056.async.js +1 -0
  85. package/static/dist/{src__pages__setting__systemLog.fc5bdc78.async.js → src__pages__setting__systemLog.cbb0a3bb.async.js} +1 -1
  86. package/static/dist/src__pages__subscription__modal.ade477c1.async.js +1 -0
  87. package/static/dist/umi.ba9d6227.js +1 -0
  88. package/version.yaml +46 -9
  89. package/docker/front.conf +0 -61
  90. package/docker/nginx.conf +0 -45
  91. package/static/dist/2995.2eb218b3.async.js +0 -1
  92. package/static/dist/3191.cc1e31cd.async.js +0 -1
  93. package/static/dist/4046.7fbcfa02.async.js +0 -1
  94. package/static/dist/5713.8519f547.async.js +0 -1
  95. package/static/dist/8851.503b1e64.async.js +0 -1
  96. package/static/dist/preload_helper.9c086410.js +0 -1
  97. package/static/dist/src__pages__crontab__index.af4cb04a.async.js +0 -1
  98. package/static/dist/src__pages__crontab__modal.21258e08.async.js +0 -1
  99. package/static/dist/src__pages__dependence__modal.6639424a.async.js +0 -1
  100. package/static/dist/src__pages__env__index.70340ba7.async.js +0 -1
  101. package/static/dist/src__pages__setting__dependence.a46e873d.async.js +0 -1
  102. package/static/dist/src__pages__setting__index.9be4775c.async.js +0 -1
  103. package/static/dist/src__pages__setting__notification.299f6b96.async.js +0 -1
  104. package/static/dist/src__pages__setting__other.60924a56.async.js +0 -1
  105. package/static/dist/src__pages__setting__security.e7371daa.async.js +0 -1
  106. package/static/dist/src__pages__subscription__modal.a7fd6a3c.async.js +0 -1
  107. package/static/dist/umi.5b8ae363.js +0 -1
@@ -5,7 +5,7 @@
5
5
  // protoc v3.17.3
6
6
  // source: back/protos/api.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ApiClient = exports.ApiService = exports.SystemNotifyRequest = exports.NotificationInfo = exports.CronDetailResponse = exports.CronDetailRequest = exports.CronResponse = exports.CronsResponse = exports.DeleteCronsRequest = exports.UpdateCronRequest = exports.CreateCronRequest = exports.CronItem = exports.ExtraScheduleItem = exports.Response = exports.EnvResponse = exports.EnvsResponse = exports.GetEnvByIdRequest = exports.UpdateEnvNamesRequest = exports.EnableEnvsRequest = exports.DisableEnvsRequest = exports.MoveEnvRequest = exports.DeleteEnvsRequest = exports.UpdateEnvRequest = exports.CreateEnvRequest = exports.GetEnvsRequest = exports.EnvItem = exports.notificationModeToJSON = exports.notificationModeFromJSON = exports.NotificationMode = exports.protobufPackage = void 0;
8
+ exports.ApiClient = exports.ApiService = exports.SystemNotifyRequest = exports.NotificationInfo = exports.CronDetailResponse = exports.CronDetailRequest = exports.CronResponse = exports.CronsResponse = exports.RunCronsRequest = exports.DisableCronsRequest = exports.EnableCronsRequest = exports.GetCronByIdRequest = exports.GetCronsRequest = exports.DeleteCronsRequest = exports.UpdateCronRequest = exports.CreateCronRequest = exports.CronItem = exports.ExtraScheduleItem = exports.Response = exports.EnvResponse = exports.EnvsResponse = exports.GetEnvByIdRequest = exports.UpdateEnvNamesRequest = exports.EnableEnvsRequest = exports.DisableEnvsRequest = exports.MoveEnvRequest = exports.DeleteEnvsRequest = exports.UpdateEnvRequest = exports.CreateEnvRequest = exports.GetEnvsRequest = exports.EnvItem = exports.notificationModeToJSON = exports.notificationModeFromJSON = exports.NotificationMode = 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");
@@ -1829,6 +1829,296 @@ exports.DeleteCronsRequest = {
1829
1829
  return message;
1830
1830
  },
1831
1831
  };
1832
+ function createBaseGetCronsRequest() {
1833
+ return { searchValue: undefined };
1834
+ }
1835
+ exports.GetCronsRequest = {
1836
+ encode(message, writer = new wire_1.BinaryWriter()) {
1837
+ if (message.searchValue !== undefined) {
1838
+ writer.uint32(10).string(message.searchValue);
1839
+ }
1840
+ return writer;
1841
+ },
1842
+ decode(input, length) {
1843
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1844
+ let end = length === undefined ? reader.len : reader.pos + length;
1845
+ const message = createBaseGetCronsRequest();
1846
+ while (reader.pos < end) {
1847
+ const tag = reader.uint32();
1848
+ switch (tag >>> 3) {
1849
+ case 1: {
1850
+ if (tag !== 10) {
1851
+ break;
1852
+ }
1853
+ message.searchValue = reader.string();
1854
+ continue;
1855
+ }
1856
+ }
1857
+ if ((tag & 7) === 4 || tag === 0) {
1858
+ break;
1859
+ }
1860
+ reader.skip(tag & 7);
1861
+ }
1862
+ return message;
1863
+ },
1864
+ fromJSON(object) {
1865
+ return { searchValue: isSet(object.searchValue) ? globalThis.String(object.searchValue) : undefined };
1866
+ },
1867
+ toJSON(message) {
1868
+ const obj = {};
1869
+ if (message.searchValue !== undefined) {
1870
+ obj.searchValue = message.searchValue;
1871
+ }
1872
+ return obj;
1873
+ },
1874
+ create(base) {
1875
+ return exports.GetCronsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1876
+ },
1877
+ fromPartial(object) {
1878
+ var _a;
1879
+ const message = createBaseGetCronsRequest();
1880
+ message.searchValue = (_a = object.searchValue) !== null && _a !== void 0 ? _a : undefined;
1881
+ return message;
1882
+ },
1883
+ };
1884
+ function createBaseGetCronByIdRequest() {
1885
+ return { id: 0 };
1886
+ }
1887
+ exports.GetCronByIdRequest = {
1888
+ encode(message, writer = new wire_1.BinaryWriter()) {
1889
+ if (message.id !== 0) {
1890
+ writer.uint32(8).int32(message.id);
1891
+ }
1892
+ return writer;
1893
+ },
1894
+ decode(input, length) {
1895
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1896
+ let end = length === undefined ? reader.len : reader.pos + length;
1897
+ const message = createBaseGetCronByIdRequest();
1898
+ while (reader.pos < end) {
1899
+ const tag = reader.uint32();
1900
+ switch (tag >>> 3) {
1901
+ case 1: {
1902
+ if (tag !== 8) {
1903
+ break;
1904
+ }
1905
+ message.id = reader.int32();
1906
+ continue;
1907
+ }
1908
+ }
1909
+ if ((tag & 7) === 4 || tag === 0) {
1910
+ break;
1911
+ }
1912
+ reader.skip(tag & 7);
1913
+ }
1914
+ return message;
1915
+ },
1916
+ fromJSON(object) {
1917
+ return { id: isSet(object.id) ? globalThis.Number(object.id) : 0 };
1918
+ },
1919
+ toJSON(message) {
1920
+ const obj = {};
1921
+ if (message.id !== 0) {
1922
+ obj.id = Math.round(message.id);
1923
+ }
1924
+ return obj;
1925
+ },
1926
+ create(base) {
1927
+ return exports.GetCronByIdRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1928
+ },
1929
+ fromPartial(object) {
1930
+ var _a;
1931
+ const message = createBaseGetCronByIdRequest();
1932
+ message.id = (_a = object.id) !== null && _a !== void 0 ? _a : 0;
1933
+ return message;
1934
+ },
1935
+ };
1936
+ function createBaseEnableCronsRequest() {
1937
+ return { ids: [] };
1938
+ }
1939
+ exports.EnableCronsRequest = {
1940
+ encode(message, writer = new wire_1.BinaryWriter()) {
1941
+ writer.uint32(10).fork();
1942
+ for (const v of message.ids) {
1943
+ writer.int32(v);
1944
+ }
1945
+ writer.join();
1946
+ return writer;
1947
+ },
1948
+ decode(input, length) {
1949
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
1950
+ let end = length === undefined ? reader.len : reader.pos + length;
1951
+ const message = createBaseEnableCronsRequest();
1952
+ while (reader.pos < end) {
1953
+ const tag = reader.uint32();
1954
+ switch (tag >>> 3) {
1955
+ case 1: {
1956
+ if (tag === 8) {
1957
+ message.ids.push(reader.int32());
1958
+ continue;
1959
+ }
1960
+ if (tag === 10) {
1961
+ const end2 = reader.uint32() + reader.pos;
1962
+ while (reader.pos < end2) {
1963
+ message.ids.push(reader.int32());
1964
+ }
1965
+ continue;
1966
+ }
1967
+ break;
1968
+ }
1969
+ }
1970
+ if ((tag & 7) === 4 || tag === 0) {
1971
+ break;
1972
+ }
1973
+ reader.skip(tag & 7);
1974
+ }
1975
+ return message;
1976
+ },
1977
+ fromJSON(object) {
1978
+ return { ids: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.ids) ? object.ids.map((e) => globalThis.Number(e)) : [] };
1979
+ },
1980
+ toJSON(message) {
1981
+ var _a;
1982
+ const obj = {};
1983
+ if ((_a = message.ids) === null || _a === void 0 ? void 0 : _a.length) {
1984
+ obj.ids = message.ids.map((e) => Math.round(e));
1985
+ }
1986
+ return obj;
1987
+ },
1988
+ create(base) {
1989
+ return exports.EnableCronsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
1990
+ },
1991
+ fromPartial(object) {
1992
+ var _a;
1993
+ const message = createBaseEnableCronsRequest();
1994
+ message.ids = ((_a = object.ids) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
1995
+ return message;
1996
+ },
1997
+ };
1998
+ function createBaseDisableCronsRequest() {
1999
+ return { ids: [] };
2000
+ }
2001
+ exports.DisableCronsRequest = {
2002
+ encode(message, writer = new wire_1.BinaryWriter()) {
2003
+ writer.uint32(10).fork();
2004
+ for (const v of message.ids) {
2005
+ writer.int32(v);
2006
+ }
2007
+ writer.join();
2008
+ return writer;
2009
+ },
2010
+ decode(input, length) {
2011
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2012
+ let end = length === undefined ? reader.len : reader.pos + length;
2013
+ const message = createBaseDisableCronsRequest();
2014
+ while (reader.pos < end) {
2015
+ const tag = reader.uint32();
2016
+ switch (tag >>> 3) {
2017
+ case 1: {
2018
+ if (tag === 8) {
2019
+ message.ids.push(reader.int32());
2020
+ continue;
2021
+ }
2022
+ if (tag === 10) {
2023
+ const end2 = reader.uint32() + reader.pos;
2024
+ while (reader.pos < end2) {
2025
+ message.ids.push(reader.int32());
2026
+ }
2027
+ continue;
2028
+ }
2029
+ break;
2030
+ }
2031
+ }
2032
+ if ((tag & 7) === 4 || tag === 0) {
2033
+ break;
2034
+ }
2035
+ reader.skip(tag & 7);
2036
+ }
2037
+ return message;
2038
+ },
2039
+ fromJSON(object) {
2040
+ return { ids: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.ids) ? object.ids.map((e) => globalThis.Number(e)) : [] };
2041
+ },
2042
+ toJSON(message) {
2043
+ var _a;
2044
+ const obj = {};
2045
+ if ((_a = message.ids) === null || _a === void 0 ? void 0 : _a.length) {
2046
+ obj.ids = message.ids.map((e) => Math.round(e));
2047
+ }
2048
+ return obj;
2049
+ },
2050
+ create(base) {
2051
+ return exports.DisableCronsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2052
+ },
2053
+ fromPartial(object) {
2054
+ var _a;
2055
+ const message = createBaseDisableCronsRequest();
2056
+ message.ids = ((_a = object.ids) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
2057
+ return message;
2058
+ },
2059
+ };
2060
+ function createBaseRunCronsRequest() {
2061
+ return { ids: [] };
2062
+ }
2063
+ exports.RunCronsRequest = {
2064
+ encode(message, writer = new wire_1.BinaryWriter()) {
2065
+ writer.uint32(10).fork();
2066
+ for (const v of message.ids) {
2067
+ writer.int32(v);
2068
+ }
2069
+ writer.join();
2070
+ return writer;
2071
+ },
2072
+ decode(input, length) {
2073
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
2074
+ let end = length === undefined ? reader.len : reader.pos + length;
2075
+ const message = createBaseRunCronsRequest();
2076
+ while (reader.pos < end) {
2077
+ const tag = reader.uint32();
2078
+ switch (tag >>> 3) {
2079
+ case 1: {
2080
+ if (tag === 8) {
2081
+ message.ids.push(reader.int32());
2082
+ continue;
2083
+ }
2084
+ if (tag === 10) {
2085
+ const end2 = reader.uint32() + reader.pos;
2086
+ while (reader.pos < end2) {
2087
+ message.ids.push(reader.int32());
2088
+ }
2089
+ continue;
2090
+ }
2091
+ break;
2092
+ }
2093
+ }
2094
+ if ((tag & 7) === 4 || tag === 0) {
2095
+ break;
2096
+ }
2097
+ reader.skip(tag & 7);
2098
+ }
2099
+ return message;
2100
+ },
2101
+ fromJSON(object) {
2102
+ return { ids: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.ids) ? object.ids.map((e) => globalThis.Number(e)) : [] };
2103
+ },
2104
+ toJSON(message) {
2105
+ var _a;
2106
+ const obj = {};
2107
+ if ((_a = message.ids) === null || _a === void 0 ? void 0 : _a.length) {
2108
+ obj.ids = message.ids.map((e) => Math.round(e));
2109
+ }
2110
+ return obj;
2111
+ },
2112
+ create(base) {
2113
+ return exports.RunCronsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
2114
+ },
2115
+ fromPartial(object) {
2116
+ var _a;
2117
+ const message = createBaseRunCronsRequest();
2118
+ message.ids = ((_a = object.ids) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
2119
+ return message;
2120
+ },
2121
+ };
1832
2122
  function createBaseCronsResponse() {
1833
2123
  return { code: 0, data: [], message: undefined };
1834
2124
  }
@@ -3487,6 +3777,51 @@ exports.ApiService = {
3487
3777
  responseSerialize: (value) => Buffer.from(exports.Response.encode(value).finish()),
3488
3778
  responseDeserialize: (value) => exports.Response.decode(value),
3489
3779
  },
3780
+ getCrons: {
3781
+ path: "/com.ql.api.Api/GetCrons",
3782
+ requestStream: false,
3783
+ responseStream: false,
3784
+ requestSerialize: (value) => Buffer.from(exports.GetCronsRequest.encode(value).finish()),
3785
+ requestDeserialize: (value) => exports.GetCronsRequest.decode(value),
3786
+ responseSerialize: (value) => Buffer.from(exports.CronsResponse.encode(value).finish()),
3787
+ responseDeserialize: (value) => exports.CronsResponse.decode(value),
3788
+ },
3789
+ getCronById: {
3790
+ path: "/com.ql.api.Api/GetCronById",
3791
+ requestStream: false,
3792
+ responseStream: false,
3793
+ requestSerialize: (value) => Buffer.from(exports.GetCronByIdRequest.encode(value).finish()),
3794
+ requestDeserialize: (value) => exports.GetCronByIdRequest.decode(value),
3795
+ responseSerialize: (value) => Buffer.from(exports.CronResponse.encode(value).finish()),
3796
+ responseDeserialize: (value) => exports.CronResponse.decode(value),
3797
+ },
3798
+ enableCrons: {
3799
+ path: "/com.ql.api.Api/EnableCrons",
3800
+ requestStream: false,
3801
+ responseStream: false,
3802
+ requestSerialize: (value) => Buffer.from(exports.EnableCronsRequest.encode(value).finish()),
3803
+ requestDeserialize: (value) => exports.EnableCronsRequest.decode(value),
3804
+ responseSerialize: (value) => Buffer.from(exports.Response.encode(value).finish()),
3805
+ responseDeserialize: (value) => exports.Response.decode(value),
3806
+ },
3807
+ disableCrons: {
3808
+ path: "/com.ql.api.Api/DisableCrons",
3809
+ requestStream: false,
3810
+ responseStream: false,
3811
+ requestSerialize: (value) => Buffer.from(exports.DisableCronsRequest.encode(value).finish()),
3812
+ requestDeserialize: (value) => exports.DisableCronsRequest.decode(value),
3813
+ responseSerialize: (value) => Buffer.from(exports.Response.encode(value).finish()),
3814
+ responseDeserialize: (value) => exports.Response.decode(value),
3815
+ },
3816
+ runCrons: {
3817
+ path: "/com.ql.api.Api/RunCrons",
3818
+ requestStream: false,
3819
+ responseStream: false,
3820
+ requestSerialize: (value) => Buffer.from(exports.RunCronsRequest.encode(value).finish()),
3821
+ requestDeserialize: (value) => exports.RunCronsRequest.decode(value),
3822
+ responseSerialize: (value) => Buffer.from(exports.Response.encode(value).finish()),
3823
+ responseDeserialize: (value) => exports.Response.decode(value),
3824
+ },
3490
3825
  };
3491
3826
  exports.ApiClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.ApiService, "com.ql.api.Api");
3492
3827
  function longToNumber(int64) {
@@ -15,10 +15,10 @@ const addCron = (call, callback) => {
15
15
  if (data_1.scheduleStacks.has(id)) {
16
16
  (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.forEach((x) => x.cancel());
17
17
  }
18
- logger_1.default.info('[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, schedule, command);
18
+ logger_1.default.info('[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, schedule, command);
19
19
  if (extra_schedules === null || extra_schedules === void 0 ? void 0 : extra_schedules.length) {
20
20
  extra_schedules.forEach((x) => {
21
- logger_1.default.info('[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, x.schedule, command);
21
+ logger_1.default.info('[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s', id, name, x.schedule, command);
22
22
  });
23
23
  }
24
24
  data_1.scheduleStacks.set(id, [
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.deleteCrons = exports.updateCron = exports.createCron = exports.getCronDetail = exports.systemNotify = exports.getEnvById = exports.updateEnvNames = exports.enableEnvs = exports.disableEnvs = exports.moveEnv = exports.deleteEnvs = exports.updateEnv = exports.createEnv = exports.getEnvs = void 0;
17
+ exports.runCrons = exports.disableCrons = exports.enableCrons = exports.getCronById = exports.getCrons = exports.deleteCrons = exports.updateCron = exports.createCron = exports.getCronDetail = exports.systemNotify = exports.getEnvById = exports.updateEnvNames = exports.enableEnvs = exports.disableEnvs = exports.moveEnv = exports.deleteEnvs = exports.updateEnv = exports.createEnv = exports.getEnvs = void 0;
18
18
  require("reflect-metadata");
19
19
  const typedi_1 = require("typedi");
20
20
  const env_1 = __importDefault(require("../services/env"));
@@ -265,4 +265,103 @@ const deleteCrons = async (call, callback) => {
265
265
  }
266
266
  };
267
267
  exports.deleteCrons = deleteCrons;
268
+ const getCrons = async (call, callback) => {
269
+ try {
270
+ const cronService = typedi_1.Container.get(cron_1.default);
271
+ const result = await cronService.crontabs({
272
+ searchValue: call.request.searchValue || '',
273
+ page: '0',
274
+ size: '0',
275
+ sorter: '',
276
+ filters: '',
277
+ queryString: '',
278
+ });
279
+ const data = result.data.map((x) => normalizeCronData(x));
280
+ callback(null, {
281
+ code: 200,
282
+ data: data.filter((x) => x !== undefined),
283
+ });
284
+ }
285
+ catch (e) {
286
+ callback(null, {
287
+ code: 500,
288
+ data: [],
289
+ message: e.message,
290
+ });
291
+ }
292
+ };
293
+ exports.getCrons = getCrons;
294
+ const getCronById = async (call, callback) => {
295
+ try {
296
+ if (!call.request.id) {
297
+ return callback(null, {
298
+ code: 400,
299
+ data: undefined,
300
+ message: 'id parameter is required',
301
+ });
302
+ }
303
+ const cronService = typedi_1.Container.get(cron_1.default);
304
+ const data = (await cronService.getDb({ id: call.request.id }));
305
+ callback(null, { code: 200, data: normalizeCronData(data) });
306
+ }
307
+ catch (e) {
308
+ callback(null, {
309
+ code: 404,
310
+ data: undefined,
311
+ message: e.message,
312
+ });
313
+ }
314
+ };
315
+ exports.getCronById = getCronById;
316
+ const enableCrons = async (call, callback) => {
317
+ try {
318
+ if (!call.request.ids || call.request.ids.length === 0) {
319
+ return callback(null, {
320
+ code: 400,
321
+ message: 'ids parameter is required',
322
+ });
323
+ }
324
+ const cronService = typedi_1.Container.get(cron_1.default);
325
+ await cronService.enabled(call.request.ids);
326
+ callback(null, { code: 200 });
327
+ }
328
+ catch (e) {
329
+ callback(e);
330
+ }
331
+ };
332
+ exports.enableCrons = enableCrons;
333
+ const disableCrons = async (call, callback) => {
334
+ try {
335
+ if (!call.request.ids || call.request.ids.length === 0) {
336
+ return callback(null, {
337
+ code: 400,
338
+ message: 'ids parameter is required',
339
+ });
340
+ }
341
+ const cronService = typedi_1.Container.get(cron_1.default);
342
+ await cronService.disabled(call.request.ids);
343
+ callback(null, { code: 200 });
344
+ }
345
+ catch (e) {
346
+ callback(e);
347
+ }
348
+ };
349
+ exports.disableCrons = disableCrons;
350
+ const runCrons = async (call, callback) => {
351
+ try {
352
+ if (!call.request.ids || call.request.ids.length === 0) {
353
+ return callback(null, {
354
+ code: 400,
355
+ message: 'ids parameter is required',
356
+ });
357
+ }
358
+ const cronService = typedi_1.Container.get(cron_1.default);
359
+ await cronService.run(call.request.ids);
360
+ callback(null, { code: 200 });
361
+ }
362
+ catch (e) {
363
+ callback(e);
364
+ }
365
+ };
366
+ exports.runCrons = runCrons;
268
367
  //# sourceMappingURL=api.js.map
@@ -10,7 +10,7 @@ const delCron = (call, callback) => {
10
10
  var _a;
11
11
  for (const id of call.request.ids) {
12
12
  if (data_1.scheduleStacks.has(id)) {
13
- logger_1.default.info('[schedule][取消定时任务], 任务ID: %s', id);
13
+ logger_1.default.info('[schedule][取消定时任务] 任务ID: %s', id);
14
14
  (_a = data_1.scheduleStacks.get(id)) === null || _a === void 0 ? void 0 : _a.forEach(x => x.cancel());
15
15
  data_1.scheduleStacks.delete(id);
16
16
  }
@@ -13,9 +13,8 @@ const check = async (call, callback) => {
13
13
  if (res.includes('200')) {
14
14
  return callback(null, { status: 1 });
15
15
  }
16
- const panelErrLog = await (0, util_1.promiseExec)(`tail -n 300 ~/.pm2/logs/panel-error.log`);
17
- const scheduleErrLog = await (0, util_1.promiseExec)(`tail -n 300 ~/.pm2/logs/schedule-error.log`);
18
- return callback(new Error(`${scheduleErrLog || ''}\n${panelErrLog || ''}\n${res}`.trim()));
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()));
19
18
  default:
20
19
  return callback(null, { status: 1 });
21
20
  }
@@ -21,7 +21,7 @@ const config_1 = __importDefault(require("../config"));
21
21
  const cron_1 = require("../data/cron");
22
22
  const child_process_1 = require("child_process");
23
23
  const promises_1 = __importDefault(require("fs/promises"));
24
- const cron_parser_1 = __importDefault(require("cron-parser"));
24
+ const cron_parser_1 = require("cron-parser");
25
25
  const util_1 = require("../config/util");
26
26
  const sequelize_1 = require("sequelize");
27
27
  const path_1 = __importDefault(require("path"));
@@ -34,6 +34,7 @@ const pickBy_1 = __importDefault(require("lodash/pickBy"));
34
34
  const omit_1 = __importDefault(require("lodash/omit"));
35
35
  const utils_1 = require("../shared/utils");
36
36
  const schedule_1 = require("../interface/schedule");
37
+ const logStreamManager_1 = require("../shared/logStreamManager");
37
38
  let CronService = class CronService {
38
39
  constructor(logger) {
39
40
  this.logger = logger;
@@ -54,9 +55,28 @@ let CronService = class CronService {
54
55
  isSpecialSchedule(schedule) {
55
56
  return this.isOnceSchedule(schedule) || this.isBootSchedule(schedule);
56
57
  }
58
+ async getLogName(cron) {
59
+ const { log_name, command, id } = cron;
60
+ if (log_name === '/dev/null') {
61
+ return log_name;
62
+ }
63
+ let uniqPath = await (0, util_1.getUniqPath)(command, `${id}`);
64
+ if (log_name) {
65
+ const normalizedLogName = log_name.startsWith('/')
66
+ ? log_name
67
+ : path_1.default.join(config_1.default.logPath, log_name);
68
+ if (normalizedLogName.startsWith(config_1.default.logPath)) {
69
+ uniqPath = log_name;
70
+ }
71
+ }
72
+ const logDirPath = path_1.default.resolve(config_1.default.logPath, `${uniqPath}`);
73
+ await promises_1.default.mkdir(logDirPath, { recursive: true });
74
+ return uniqPath;
75
+ }
57
76
  async create(payload) {
58
77
  const tab = new cron_1.Crontab(payload);
59
78
  tab.saved = false;
79
+ tab.log_name = await this.getLogName(tab);
60
80
  const doc = await this.insert(tab);
61
81
  if ((0, util_1.isDemoEnv)()) {
62
82
  return doc;
@@ -82,6 +102,7 @@ let CronService = class CronService {
82
102
  const doc = await this.getDb({ id: payload.id });
83
103
  const tab = new cron_1.Crontab(Object.assign(Object.assign({}, doc), payload));
84
104
  tab.saved = false;
105
+ tab.log_name = await this.getLogName(tab);
85
106
  const newDoc = await this.updateDb(tab);
86
107
  if (doc.isDisabled === 1 || (0, util_1.isDemoEnv)()) {
87
108
  return newDoc;
@@ -384,13 +405,14 @@ let CronService = class CronService {
384
405
  async stop(ids) {
385
406
  const docs = await cron_1.CrontabModel.findAll({ where: { id: ids } });
386
407
  for (const doc of docs) {
387
- if (doc.pid) {
388
- try {
389
- await (0, util_1.killTask)(doc.pid);
390
- }
391
- catch (error) {
392
- this.logger.error(error);
393
- }
408
+ // Kill all running instances of this task
409
+ try {
410
+ const command = this.makeCommand(doc);
411
+ await (0, util_1.killAllTasks)(command);
412
+ this.logger.info(`[panel][停止所有运行中的任务实例] 任务ID: ${doc.id}, 命令: ${command}`);
413
+ }
414
+ catch (error) {
415
+ this.logger.error(`[panel][停止任务失败] 任务ID: ${doc.id}, 错误: ${error}`);
394
416
  }
395
417
  }
396
418
  await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.idle, pid: undefined }, { where: { id: ids } });
@@ -398,7 +420,6 @@ let CronService = class CronService {
398
420
  async runSingle(cronId) {
399
421
  return pLimit_1.default.manualRunWithCronLimit(() => {
400
422
  return new Promise(async (resolve) => {
401
- var _a;
402
423
  const cron = await this.getDb({ id: cronId });
403
424
  const params = {
404
425
  name: cron.name,
@@ -411,30 +432,32 @@ let CronService = class CronService {
411
432
  return;
412
433
  }
413
434
  this.logger.info(`[panel][开始执行任务] 参数: ${JSON.stringify(params)}`);
414
- let { id, command, log_path } = cron;
415
- const uniqPath = await (0, util_1.getUniqPath)(command, `${id}`);
435
+ let { id, command, log_name } = cron;
436
+ const uniqPath = log_name === '/dev/null' || !log_name
437
+ ? await (0, util_1.getUniqPath)(command, `${id}`)
438
+ : log_name;
416
439
  const logTime = (0, dayjs_1.default)().format('YYYY-MM-DD-HH-mm-ss-SSS');
417
440
  const logDirPath = path_1.default.resolve(config_1.default.logPath, `${uniqPath}`);
418
- if ((_a = log_path === null || log_path === void 0 ? void 0 : log_path.split('/')) === null || _a === void 0 ? void 0 : _a.every((x) => x !== uniqPath)) {
419
- await promises_1.default.mkdir(logDirPath, { recursive: true });
420
- }
441
+ await promises_1.default.mkdir(logDirPath, { recursive: true });
421
442
  const logPath = `${uniqPath}/${logTime}.log`;
422
443
  const absolutePath = path_1.default.resolve(config_1.default.logPath, `${logPath}`);
423
444
  const cp = (0, cross_spawn_1.spawn)(`real_log_path=${logPath} no_delay=true ${this.makeCommand(cron, true)}`, { shell: '/bin/bash' });
424
445
  await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.running, pid: cp.pid, log_path: logPath }, { where: { id } });
425
446
  cp.stdout.on('data', async (data) => {
426
- await promises_1.default.appendFile(absolutePath, data.toString());
447
+ await logStreamManager_1.logStreamManager.write(absolutePath, data.toString());
427
448
  });
428
449
  cp.stderr.on('data', async (data) => {
429
450
  this.logger.info('[panel][执行任务失败] 命令: %s, 错误信息: %j', command, data.toString());
430
- await promises_1.default.appendFile(absolutePath, data.toString());
451
+ await logStreamManager_1.logStreamManager.write(absolutePath, data.toString());
431
452
  });
432
453
  cp.on('error', async (err) => {
433
454
  this.logger.error('[panel][创建任务失败] 命令: %s, 错误信息: %j', command, err);
434
- await promises_1.default.appendFile(absolutePath, JSON.stringify(err));
455
+ await logStreamManager_1.logStreamManager.write(absolutePath, JSON.stringify(err));
435
456
  });
436
457
  cp.on('exit', async (code) => {
437
458
  this.logger.info('[panel][执行任务结束] 参数: %s, 退出码: %j', JSON.stringify(params), code);
459
+ // Close the stream after task completion
460
+ await logStreamManager_1.logStreamManager.closeStream(absolutePath);
438
461
  await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.idle, pid: undefined }, { where: { id } });
439
462
  resolve(Object.assign(Object.assign({}, params), { pid: cp.pid, code }));
440
463
  });
@@ -467,6 +490,9 @@ let CronService = class CronService {
467
490
  if (!doc) {
468
491
  return '';
469
492
  }
493
+ if (doc.log_name === '/dev/null') {
494
+ return '日志设置为忽略';
495
+ }
470
496
  const absolutePath = path_1.default.resolve(config_1.default.logPath, `${doc.log_path}`);
471
497
  const logFileExist = doc.log_path && (await (0, util_1.fileExist)(absolutePath));
472
498
  if (logFileExist) {
@@ -492,7 +518,7 @@ let CronService = class CronService {
492
518
  return (await Promise.all(files.map(async (x) => ({
493
519
  filename: x,
494
520
  directory: relativeDir.replace(config_1.default.logPath, ''),
495
- time: (await promises_1.default.lstat(`${dir}/${x}`)).mtime.getTime(),
521
+ time: (await promises_1.default.lstat(`${dir}/${x}`)).birthtimeMs,
496
522
  })))).sort((a, b) => b.time - a.time);
497
523
  }
498
524
  else {
@@ -505,6 +531,10 @@ let CronService = class CronService {
505
531
  command = `${const_1.TASK_PREFIX}${tab.command}`;
506
532
  }
507
533
  let commandVariable = `real_time=${Boolean(realTime)} no_tee=true ID=${tab.id} `;
534
+ // Only include log_name if it has a truthy value to avoid passing null/undefined to shell
535
+ if (tab.log_name) {
536
+ commandVariable += `log_name=${tab.log_name} `;
537
+ }
508
538
  if (tab.task_before) {
509
539
  commandVariable += `task_before='${tab.task_before
510
540
  .replace(/'/g, "'\\''")
@@ -544,7 +574,11 @@ let CronService = class CronService {
544
574
  await cron_1.CrontabModel.update({ saved: true }, { where: {} });
545
575
  }
546
576
  importCrontab() {
547
- (0, child_process_1.exec)('crontab -l', (error, stdout, stderr) => {
577
+ (0, child_process_1.exec)('crontab -l', (error, stdout) => {
578
+ if (error) {
579
+ const errorMsg = error.message || String(error);
580
+ this.logger.error('[crontab] Failed to read system crontab:', errorMsg);
581
+ }
548
582
  const lines = stdout.split('\n');
549
583
  const namePrefix = new Date().getTime();
550
584
  lines.reverse().forEach(async (line, index) => {
@@ -554,7 +588,7 @@ let CronService = class CronService {
554
588
  const schedule = line.replace(command, '').trim();
555
589
  if (command &&
556
590
  schedule &&
557
- cron_parser_1.default.parseExpression(schedule).hasNext()) {
591
+ cron_parser_1.CronExpressionParser.parse(schedule).hasNext()) {
558
592
  const name = namePrefix + '_' + index;
559
593
  const _crontab = await cron_1.CrontabModel.findOne({
560
594
  where: { command, schedule },