ee-core 4.1.2 → 4.1.4

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 (131) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/app/application.d.ts +5 -5
  4. package/app/application.js +30 -30
  5. package/app/boot.d.ts +5 -5
  6. package/app/boot.js +80 -80
  7. package/app/dir.d.ts +1 -1
  8. package/app/dir.js +26 -26
  9. package/app/events.d.ts +14 -14
  10. package/app/events.js +55 -55
  11. package/app/index.d.ts +2 -2
  12. package/app/index.js +6 -6
  13. package/config/config_loader.d.ts +13 -13
  14. package/config/config_loader.js +65 -65
  15. package/config/default_config.d.ts +95 -95
  16. package/config/default_config.js +111 -111
  17. package/config/index.d.ts +28 -28
  18. package/config/index.js +24 -24
  19. package/const/channel.d.ts +16 -16
  20. package/const/channel.js +27 -27
  21. package/controller/controller_loader.d.ts +9 -9
  22. package/controller/controller_loader.js +77 -77
  23. package/controller/index.d.ts +2 -2
  24. package/controller/index.js +24 -24
  25. package/core/index.d.ts +2 -2
  26. package/core/index.js +11 -11
  27. package/core/loader/file_loader.d.ts +66 -66
  28. package/core/loader/file_loader.js +211 -211
  29. package/core/utils/index.d.ts +12 -12
  30. package/core/utils/index.js +83 -83
  31. package/core/utils/timing.d.ts +22 -22
  32. package/core/utils/timing.js +78 -78
  33. package/cross/cross.d.ts +19 -19
  34. package/cross/cross.js +151 -151
  35. package/cross/crossProcess.d.ts +29 -29
  36. package/cross/crossProcess.js +172 -172
  37. package/cross/index.d.ts +2 -2
  38. package/cross/index.js +8 -8
  39. package/electron/app/index.d.ts +5 -5
  40. package/electron/app/index.js +48 -48
  41. package/electron/index.d.ts +3 -3
  42. package/electron/index.js +15 -15
  43. package/electron/window/index.d.ts +6 -6
  44. package/electron/window/index.js +268 -268
  45. package/exception/index.d.ts +9 -9
  46. package/exception/index.js +100 -100
  47. package/html/boot.html +98 -98
  48. package/html/cross-failure.html +28 -28
  49. package/html/failure.html +28 -28
  50. package/html/index.d.ts +1 -1
  51. package/html/index.js +10 -10
  52. package/index.d.ts +2 -2
  53. package/index.js +6 -6
  54. package/jobs/child/app.d.ts +1 -1
  55. package/jobs/child/app.js +69 -69
  56. package/jobs/child/index.d.ts +13 -13
  57. package/jobs/child/index.js +85 -85
  58. package/jobs/child/jobProcess.d.ts +16 -16
  59. package/jobs/child/jobProcess.js +133 -133
  60. package/jobs/child-pool/index.d.ts +26 -26
  61. package/jobs/child-pool/index.js +190 -190
  62. package/jobs/index.d.ts +3 -3
  63. package/jobs/index.js +6 -6
  64. package/jobs/load-balancer/algorithm/index.d.ts +4 -4
  65. package/jobs/load-balancer/algorithm/index.js +11 -11
  66. package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
  67. package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
  68. package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
  69. package/jobs/load-balancer/algorithm/polling.js +11 -11
  70. package/jobs/load-balancer/algorithm/random.d.ts +2 -2
  71. package/jobs/load-balancer/algorithm/random.js +9 -9
  72. package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
  73. package/jobs/load-balancer/algorithm/specify.js +14 -14
  74. package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
  75. package/jobs/load-balancer/algorithm/weights.js +21 -21
  76. package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
  77. package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
  78. package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
  79. package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
  80. package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
  81. package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
  82. package/jobs/load-balancer/consts.d.ts +8 -8
  83. package/jobs/load-balancer/consts.js +9 -9
  84. package/jobs/load-balancer/index.d.ts +96 -96
  85. package/jobs/load-balancer/index.js +201 -201
  86. package/jobs/load-balancer/scheduler.d.ts +16 -16
  87. package/jobs/load-balancer/scheduler.js +31 -31
  88. package/loader/index.d.ts +9 -9
  89. package/loader/index.js +99 -98
  90. package/log/index.d.ts +5 -5
  91. package/log/index.js +85 -85
  92. package/log/logger.d.ts +1 -1
  93. package/log/logger.js +94 -94
  94. package/message/childMessage.d.ts +10 -10
  95. package/message/childMessage.js +43 -43
  96. package/message/index.d.ts +3 -3
  97. package/message/index.js +9 -9
  98. package/package.json +42 -42
  99. package/ps/index.d.ts +39 -39
  100. package/ps/index.js +294 -294
  101. package/socket/httpServer.d.ts +8 -8
  102. package/socket/httpServer.js +199 -199
  103. package/socket/index.d.ts +10 -10
  104. package/socket/index.js +64 -64
  105. package/socket/ipcServer.d.ts +9 -9
  106. package/socket/ipcServer.js +105 -105
  107. package/socket/socketServer.d.ts +10 -10
  108. package/socket/socketServer.js +81 -81
  109. package/storage/index.d.ts +4 -4
  110. package/storage/index.js +6 -6
  111. package/storage/sqliteStorage.d.ts +16 -16
  112. package/storage/sqliteStorage.js +123 -123
  113. package/tsconfig.json +13 -13
  114. package/utils/extend.d.ts +2 -2
  115. package/utils/extend.js +77 -77
  116. package/utils/helper.d.ts +14 -14
  117. package/utils/helper.js +206 -206
  118. package/utils/index.d.ts +10 -10
  119. package/utils/index.js +167 -167
  120. package/utils/ip.d.ts +2 -2
  121. package/utils/ip.js +221 -221
  122. package/utils/is.d.ts +14 -14
  123. package/utils/is.js +111 -111
  124. package/utils/json.d.ts +5 -5
  125. package/utils/json.js +79 -79
  126. package/utils/pargv.d.ts +3 -3
  127. package/utils/pargv.js +267 -267
  128. package/utils/port/index.d.ts +1 -1
  129. package/utils/port/index.js +125 -125
  130. package/utils/wrap.d.ts +4 -4
  131. package/utils/wrap.js +40 -40
package/loader/index.js CHANGED
@@ -1,98 +1,99 @@
1
- const is = require('is-type-of');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const CoreUtils = require('../core/utils');
5
- const { getElectronDir } = require('../ps');
6
-
7
- // 加载单个文件(如果是函数,将被执行)
8
- function loadFile(filepath, ...inject) {
9
- const isAbsolute = path.isAbsolute(filepath);
10
- if (!isAbsolute) {
11
- filepath = path.join(getElectronDir(), filepath);
12
- }
13
-
14
- filepath = filepath && resolveModule(filepath);
15
- if (!fs.existsSync(filepath)) {
16
- let errorMsg = `[ee-core] [loader/index] loadFile ${filepath} does not exist`;
17
- throw new Error(errorMsg);
18
- }
19
-
20
- let ret = CoreUtils.loadFile(filepath);
21
- if (is.function(ret) && !is.class(ret) && !CoreUtils.isBytecodeClass(ret)) {
22
- ret = ret(...inject);
23
- }
24
- return ret;
25
- }
26
-
27
- // requireFile
28
- function requireFile(filepath) {
29
- return CoreUtils.loadFile(filepath);
30
- }
31
-
32
- // 加载并运行文件
33
- function execFile(filepath, ...inject) {
34
- let ret = CoreUtils.loadFile(filepath);
35
- if (is.class(ret) || CoreUtils.isBytecodeClass(ret)) {
36
- ret = new ret(inject);
37
- } else if (is.function(ret)) {
38
- ret = ret(inject);
39
- }
40
-
41
- return ret;
42
- }
43
-
44
- // 模块的绝对路径
45
- function resolveModule(filepath) {
46
- let fullpath;
47
- try {
48
- fullpath = require.resolve(filepath);
49
- } catch (e) {
50
-
51
- // 特殊后缀处理
52
- if (filepath && (filepath.endsWith('.defalut') || filepath.endsWith('.prod'))) {
53
- fullpath = filepath + '.jsc';
54
- } else if (filepath && filepath.endsWith('.js')) {
55
- fullpath = filepath + 'c';
56
- }
57
-
58
- if (!fs.existsSync(filepath) && !fs.existsSync(fullpath)) {
59
- let files = { filepath, fullpath }
60
- console.warn(`[ee-core] [loader] resolveModule unknow filepath: ${files}`)
61
- return undefined;
62
- }
63
- }
64
-
65
- return fullpath;
66
- }
67
-
68
- // 获取electron目录下文件的绝对路径
69
- function getFullpath(filepath) {
70
- let fullpath;
71
- const isAbsolute = path.isAbsolute(filepath);
72
- if (!isAbsolute) {
73
- filepath = path.join(getElectronDir(), filepath);
74
- }
75
-
76
- fullpath = resolveModule(filepath);
77
- if (!fs.existsSync(fullpath)) {
78
- throw new Error(`[ee-core] [loader] getFullpath filepath ${filepath} not exists`);
79
- }
80
-
81
- return fullpath;
82
- }
83
-
84
- module.exports = {
85
- loadFile,
86
- execFile,
87
- requireFile,
88
- resolveModule,
89
- getFullpath,
90
- }
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
1
+ const is = require('is-type-of');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const CoreUtils = require('../core/utils');
5
+ const { getElectronDir } = require('../ps');
6
+
7
+ // 加载单个文件(如果是函数,将被执行)
8
+ function loadFile(filepath, ...inject) {
9
+ let fullpath = filepath;
10
+ const isAbsolute = path.isAbsolute(fullpath);
11
+ if (!isAbsolute) {
12
+ fullpath = path.join(getElectronDir(), fullpath);
13
+ }
14
+
15
+ fullpath = fullpath && resolveModule(fullpath);
16
+ if (!fs.existsSync(fullpath)) {
17
+ let errorMsg = `[ee-core] [loader/index] loadFile ${filepath} does not exist`;
18
+ throw new Error(errorMsg);
19
+ }
20
+
21
+ let ret = CoreUtils.loadFile(fullpath);
22
+ if (is.function(ret) && !is.class(ret) && !CoreUtils.isBytecodeClass(ret)) {
23
+ ret = ret(...inject);
24
+ }
25
+ return ret;
26
+ }
27
+
28
+ // requireFile
29
+ function requireFile(filepath) {
30
+ return CoreUtils.loadFile(filepath);
31
+ }
32
+
33
+ // 加载并运行文件
34
+ function execFile(filepath, ...inject) {
35
+ let ret = CoreUtils.loadFile(filepath);
36
+ if (is.class(ret) || CoreUtils.isBytecodeClass(ret)) {
37
+ ret = new ret(inject);
38
+ } else if (is.function(ret)) {
39
+ ret = ret(inject);
40
+ }
41
+
42
+ return ret;
43
+ }
44
+
45
+ // 模块的绝对路径
46
+ function resolveModule(filepath) {
47
+ let fullpath;
48
+ try {
49
+ fullpath = require.resolve(filepath);
50
+ } catch (e) {
51
+
52
+ // 特殊后缀处理
53
+ if (filepath && (filepath.endsWith('.defalut') || filepath.endsWith('.prod'))) {
54
+ fullpath = filepath + '.jsc';
55
+ } else if (filepath && filepath.endsWith('.js')) {
56
+ fullpath = filepath + 'c';
57
+ }
58
+
59
+ if (!fs.existsSync(filepath) && !fs.existsSync(fullpath)) {
60
+ let files = { filepath, fullpath }
61
+ console.warn(`[ee-core] [loader] resolveModule unknow filepath: ${files}`)
62
+ return undefined;
63
+ }
64
+ }
65
+
66
+ return fullpath;
67
+ }
68
+
69
+ // 获取electron目录下文件的绝对路径
70
+ function getFullpath(filepath) {
71
+ let fullpath;
72
+ const isAbsolute = path.isAbsolute(filepath);
73
+ if (!isAbsolute) {
74
+ filepath = path.join(getElectronDir(), filepath);
75
+ }
76
+
77
+ fullpath = resolveModule(filepath);
78
+ if (!fs.existsSync(fullpath)) {
79
+ throw new Error(`[ee-core] [loader] getFullpath filepath ${filepath} not exists`);
80
+ }
81
+
82
+ return fullpath;
83
+ }
84
+
85
+ module.exports = {
86
+ loadFile,
87
+ execFile,
88
+ requireFile,
89
+ resolveModule,
90
+ getFullpath,
91
+ }
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
package/log/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EggLoggers, Logger } from "egg-logger";
2
- export declare function createLog(config: any): EggLoggers;
3
- export declare function loadLog(): EggLoggers;
4
- export declare const logger: Logger;
5
- export declare const coreLogger: Logger;
1
+ import { EggLoggers, Logger } from "egg-logger";
2
+ export declare function createLog(config: any): EggLoggers;
3
+ export declare function loadLog(): EggLoggers;
4
+ export declare const logger: Logger;
5
+ export declare const coreLogger: Logger;
package/log/index.js CHANGED
@@ -1,86 +1,86 @@
1
- 'use strict';
2
-
3
- const dayjs = require('dayjs');
4
- const { create } = require('./logger');
5
-
6
- const Instance = {
7
- eelog: null,
8
- logger: {},
9
- coreLogger: {},
10
- };
11
- let logDate = 0;
12
- const logProperties = ['error', 'warn', 'info', 'debug'];
13
-
14
- // define logger/coreLogger properties
15
- defineLoggerProperty();
16
- defineCoreLoggerProperty();
17
-
18
- // Create a log instance
19
- function createLog(config) {
20
- _delCache();
21
- const eeLog = create(config);
22
-
23
- return eeLog;
24
- }
25
-
26
- function loadLog() {
27
- Instance.eelog = createLog();
28
- return Instance.eelog;
29
- }
30
-
31
- function defineLoggerProperty() {
32
- for (const property of logProperties) {
33
- Object.defineProperty(Instance.logger, property, {
34
- get() {
35
- //console.log('emit logger property: ', property);
36
- let log = getLogger();
37
- let val = log[property].bind(log);
38
- return val;
39
- },
40
- });
41
- }
42
- }
43
-
44
- function defineCoreLoggerProperty() {
45
- for (const property of logProperties) {
46
- Object.defineProperty(Instance.coreLogger, property, {
47
- get() {
48
- let log = getCoreLogger();
49
- let val = log[property].bind(log);
50
- return val;
51
- },
52
- });
53
- }
54
- }
55
-
56
- function _delCache() {
57
- const now = parseInt(dayjs().format('YYYYMMDD'));
58
- if (logDate != now) {
59
- logDate = now;
60
- Instance.eelog = null;
61
- }
62
- }
63
-
64
- function getLogger() {
65
- _delCache();
66
- if (!Instance.eelog) {
67
- loadLog();
68
- }
69
-
70
- return Instance.eelog["logger"];
71
- }
72
-
73
- function getCoreLogger() {
74
- _delCache();
75
- if (!Instance.eelog) {
76
- loadLog();
77
- }
78
- return Instance.eelog["coreLogger"];
79
- }
80
-
81
- module.exports = {
82
- createLog,
83
- loadLog,
84
- logger: Instance.logger,
85
- coreLogger: Instance.coreLogger
1
+ 'use strict';
2
+
3
+ const dayjs = require('dayjs');
4
+ const { create } = require('./logger');
5
+
6
+ const Instance = {
7
+ eelog: null,
8
+ logger: {},
9
+ coreLogger: {},
10
+ };
11
+ let logDate = 0;
12
+ const logProperties = ['error', 'warn', 'info', 'debug'];
13
+
14
+ // define logger/coreLogger properties
15
+ defineLoggerProperty();
16
+ defineCoreLoggerProperty();
17
+
18
+ // Create a log instance
19
+ function createLog(config) {
20
+ _delCache();
21
+ const eeLog = create(config);
22
+
23
+ return eeLog;
24
+ }
25
+
26
+ function loadLog() {
27
+ Instance.eelog = createLog();
28
+ return Instance.eelog;
29
+ }
30
+
31
+ function defineLoggerProperty() {
32
+ for (const property of logProperties) {
33
+ Object.defineProperty(Instance.logger, property, {
34
+ get() {
35
+ //console.log('emit logger property: ', property);
36
+ let log = getLogger();
37
+ let val = log[property].bind(log);
38
+ return val;
39
+ },
40
+ });
41
+ }
42
+ }
43
+
44
+ function defineCoreLoggerProperty() {
45
+ for (const property of logProperties) {
46
+ Object.defineProperty(Instance.coreLogger, property, {
47
+ get() {
48
+ let log = getCoreLogger();
49
+ let val = log[property].bind(log);
50
+ return val;
51
+ },
52
+ });
53
+ }
54
+ }
55
+
56
+ function _delCache() {
57
+ const now = parseInt(dayjs().format('YYYYMMDD'));
58
+ if (logDate != now) {
59
+ logDate = now;
60
+ Instance.eelog = null;
61
+ }
62
+ }
63
+
64
+ function getLogger() {
65
+ _delCache();
66
+ if (!Instance.eelog) {
67
+ loadLog();
68
+ }
69
+
70
+ return Instance.eelog["logger"];
71
+ }
72
+
73
+ function getCoreLogger() {
74
+ _delCache();
75
+ if (!Instance.eelog) {
76
+ loadLog();
77
+ }
78
+ return Instance.eelog["coreLogger"];
79
+ }
80
+
81
+ module.exports = {
82
+ createLog,
83
+ loadLog,
84
+ logger: Instance.logger,
85
+ coreLogger: Instance.coreLogger
86
86
  };
package/log/logger.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { EggLoggers } from "egg-logger";
1
+ import { EggLoggers } from "egg-logger";
2
2
  export declare function create(config?: {}): EggLoggers;
package/log/logger.js CHANGED
@@ -1,95 +1,95 @@
1
- 'use strict';
2
-
3
- const debug = require('debug')('ee-core:log:logger');
4
- const Loggers = require('egg-logger').EggLoggers;
5
- const dayjs = require('dayjs');
6
- const path = require('path');
7
- const { extend } = require('../utils/extend');
8
- const { getConfig } = require('../config');
9
- const { getLogDir, env, isDev } = require('../ps');
10
-
11
- let LogDate = 0;
12
- const TmpFileName = {
13
- appLogName: '',
14
- coreLogName: '',
15
- errorLogName: '',
16
- }
17
-
18
- // 创建
19
- function create(config = {}) {
20
- let opt = {};
21
-
22
- if (Object.keys(config).length == 0) {
23
- const defaultConfig = {
24
- logger: {
25
- type: 'application',
26
- dir: getLogDir(),
27
- env: env(),
28
- consoleLevel: 'INFO',
29
- disableConsoleAfterReady: !isDev(),
30
- coreLogger: {},
31
- allowDebugAtProd: false,
32
- agentLogName: 'ee-agent.log',
33
- rotator: 'day',
34
- },
35
- customLogger: {}
36
- };
37
- const sysConfig = getConfig();
38
- opt = extend(true, defaultConfig, {
39
- logger: sysConfig.logger,
40
- customLogger: sysConfig.customLogger || {}
41
- });
42
- } else {
43
- opt.logger = config.logger;
44
- opt.customLogger = config.customLogger;
45
- }
46
-
47
- if (Object.keys(opt).length == 0) {
48
- throw new Error("logger config is null");
49
- }
50
-
51
- let rotateType = opt.logger.rotator;
52
- if (rotateType == 'day') {
53
- opt = _rotateByDay(opt);
54
- }
55
-
56
- debug('[create] opt:%j', opt);
57
- const loggers = new Loggers(opt);
58
-
59
- return loggers;
60
- }
61
-
62
- /**
63
- * 按天分割
64
- */
65
- function _rotateByDay(logOpt) {
66
- const now = parseInt(dayjs().format('YYYYMMDD'));
67
- if (LogDate != now) {
68
- LogDate = now;
69
-
70
- // 保存一个临时文件名,防止文件名按日期累加
71
- if (TmpFileName.appLogName.length == 0) {
72
- TmpFileName.appLogName = logOpt.logger.appLogName;
73
- }
74
- if (TmpFileName.coreLogName.length == 0) {
75
- TmpFileName.coreLogName = logOpt.logger.coreLogName;
76
- }
77
- if (TmpFileName.errorLogName.length == 0) {
78
- TmpFileName.errorLogName = logOpt.logger.errorLogName;
79
- }
80
-
81
- const {appLogName, coreLogName, errorLogName} = TmpFileName;
82
- const appLogExtname = path.extname(appLogName);
83
- const coreLogExtname = path.extname(coreLogName);
84
- const errorLogExtname = path.extname(errorLogName);
85
- logOpt.logger.appLogName = path.basename(appLogName, appLogExtname) + '-' + now + appLogExtname;
86
- logOpt.logger.coreLogName = path.basename(coreLogName, coreLogExtname) + '-' + now + coreLogExtname;
87
- logOpt.logger.errorLogName = path.basename(errorLogName, errorLogExtname) + '-' + now + errorLogExtname;
88
- }
89
-
90
- return logOpt;
91
- }
92
-
93
- module.exports = {
94
- create
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:log:logger');
4
+ const Loggers = require('egg-logger').EggLoggers;
5
+ const dayjs = require('dayjs');
6
+ const path = require('path');
7
+ const { extend } = require('../utils/extend');
8
+ const { getConfig } = require('../config');
9
+ const { getLogDir, env, isDev } = require('../ps');
10
+
11
+ let LogDate = 0;
12
+ const TmpFileName = {
13
+ appLogName: '',
14
+ coreLogName: '',
15
+ errorLogName: '',
16
+ }
17
+
18
+ // 创建
19
+ function create(config = {}) {
20
+ let opt = {};
21
+
22
+ if (Object.keys(config).length == 0) {
23
+ const defaultConfig = {
24
+ logger: {
25
+ type: 'application',
26
+ dir: getLogDir(),
27
+ env: env(),
28
+ consoleLevel: 'INFO',
29
+ disableConsoleAfterReady: !isDev(),
30
+ coreLogger: {},
31
+ allowDebugAtProd: false,
32
+ agentLogName: 'ee-agent.log',
33
+ rotator: 'day',
34
+ },
35
+ customLogger: {}
36
+ };
37
+ const sysConfig = getConfig();
38
+ opt = extend(true, defaultConfig, {
39
+ logger: sysConfig.logger,
40
+ customLogger: sysConfig.customLogger || {}
41
+ });
42
+ } else {
43
+ opt.logger = config.logger;
44
+ opt.customLogger = config.customLogger;
45
+ }
46
+
47
+ if (Object.keys(opt).length == 0) {
48
+ throw new Error("logger config is null");
49
+ }
50
+
51
+ let rotateType = opt.logger.rotator;
52
+ if (rotateType == 'day') {
53
+ opt = _rotateByDay(opt);
54
+ }
55
+
56
+ debug('[create] opt:%j', opt);
57
+ const loggers = new Loggers(opt);
58
+
59
+ return loggers;
60
+ }
61
+
62
+ /**
63
+ * 按天分割
64
+ */
65
+ function _rotateByDay(logOpt) {
66
+ const now = parseInt(dayjs().format('YYYYMMDD'));
67
+ if (LogDate != now) {
68
+ LogDate = now;
69
+
70
+ // 保存一个临时文件名,防止文件名按日期累加
71
+ if (TmpFileName.appLogName.length == 0) {
72
+ TmpFileName.appLogName = logOpt.logger.appLogName;
73
+ }
74
+ if (TmpFileName.coreLogName.length == 0) {
75
+ TmpFileName.coreLogName = logOpt.logger.coreLogName;
76
+ }
77
+ if (TmpFileName.errorLogName.length == 0) {
78
+ TmpFileName.errorLogName = logOpt.logger.errorLogName;
79
+ }
80
+
81
+ const {appLogName, coreLogName, errorLogName} = TmpFileName;
82
+ const appLogExtname = path.extname(appLogName);
83
+ const coreLogExtname = path.extname(coreLogName);
84
+ const errorLogExtname = path.extname(errorLogName);
85
+ logOpt.logger.appLogName = path.basename(appLogName, appLogExtname) + '-' + now + appLogExtname;
86
+ logOpt.logger.coreLogName = path.basename(coreLogName, coreLogExtname) + '-' + now + coreLogExtname;
87
+ logOpt.logger.errorLogName = path.basename(errorLogName, errorLogExtname) + '-' + now + errorLogExtname;
88
+ }
89
+
90
+ return logOpt;
91
+ }
92
+
93
+ module.exports = {
94
+ create
95
95
  };
@@ -1,10 +1,10 @@
1
- export declare class ChildMessage {
2
- // 向主进程发消息 for ChildJob 实例
3
- sendToMain(eventName: string, params?: {}): boolean;
4
- // 向主进程发消息 for task 实例
5
- send(eventName: string, params: {}, receiver?: string): boolean;
6
- // 进程退出
7
- exit(code?: number): never;
8
- // 发送错误到控制台
9
- sendErrorToTerminal(err: any): void;
10
- }
1
+ export declare class ChildMessage {
2
+ // 向主进程发消息 for ChildJob 实例
3
+ sendToMain(eventName: string, params?: {}): boolean;
4
+ // 向主进程发消息 for task 实例
5
+ send(eventName: string, params: {}, receiver?: string): boolean;
6
+ // 进程退出
7
+ exit(code?: number): never;
8
+ // 发送错误到控制台
9
+ sendErrorToTerminal(err: any): void;
10
+ }