@tachybase/module-worker-thread 1.5.1 → 1.6.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.
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.
|
|
4
|
-
"@tachybase/schema": "1.
|
|
3
|
+
"@tachybase/client": "1.6.1",
|
|
4
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
5
5
|
"antd": "5.22.5",
|
|
6
|
-
"@tachybase/
|
|
7
|
-
"@tachybase/loader": "1.3.52",
|
|
6
|
+
"@tachybase/loader": "1.6.0-alpha.9",
|
|
8
7
|
"dayjs": "1.11.13",
|
|
9
|
-
"@
|
|
10
|
-
"@
|
|
11
|
-
"@tachybase/module-
|
|
8
|
+
"@tachybase/globals": "1.6.0-alpha.9",
|
|
9
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
10
|
+
"@tachybase/module-collection": "1.6.1",
|
|
11
|
+
"@tachybase/module-user": "1.6.1"
|
|
12
12
|
};
|
|
File without changes
|
package/dist/server/intercept.js
CHANGED
|
@@ -22,7 +22,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
));
|
|
23
23
|
var import_node_module = require("node:module");
|
|
24
24
|
var import_node_worker_threads = require("node:worker_threads");
|
|
25
|
-
var import_globals = __toESM(require("@tachybase/globals"));
|
|
26
25
|
var import_loader = require("@tachybase/loader");
|
|
27
26
|
var import_dayjs = __toESM(require("dayjs"));
|
|
28
27
|
var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat"));
|
|
@@ -42,7 +41,9 @@ var import_weekday = __toESM(require("dayjs/plugin/weekday"));
|
|
|
42
41
|
var import_weekOfYear = __toESM(require("dayjs/plugin/weekOfYear"));
|
|
43
42
|
var import_weekYear = __toESM(require("dayjs/plugin/weekYear"));
|
|
44
43
|
if (!import_node_worker_threads.isMainThread) {
|
|
45
|
-
const
|
|
44
|
+
const globalsModule = require("@tachybase/globals");
|
|
45
|
+
const TachybaseGlobal = globalsModule.default || globalsModule;
|
|
46
|
+
const globals = TachybaseGlobal.getInstance(import_node_worker_threads.workerData.initData);
|
|
46
47
|
const lookingPaths = globals.get("WORKER_PATHS");
|
|
47
48
|
const whitelists = new Set(globals.get("WORKER_MODULES"));
|
|
48
49
|
const originalLoad = import_node_module.Module._load;
|
|
@@ -96,6 +96,10 @@ const _WorkerManager = class _WorkerManager {
|
|
|
96
96
|
async addWorker() {
|
|
97
97
|
const maxMemory = process.env.WORKER_MAX_MEMORY || 4096;
|
|
98
98
|
const maxOldSpaceSize = `--max-old-space-size=${maxMemory}`;
|
|
99
|
+
const workerEnv = {
|
|
100
|
+
...process.env,
|
|
101
|
+
NODE_OPTIONS: maxOldSpaceSize
|
|
102
|
+
};
|
|
99
103
|
let worker;
|
|
100
104
|
if (this.isProd) {
|
|
101
105
|
worker = new import_node_worker_threads.Worker(import_node_path.default.resolve(__dirname, `${import_constants.WORKER_FILE}.js`), {
|
|
@@ -104,10 +108,7 @@ const _WorkerManager = class _WorkerManager {
|
|
|
104
108
|
databaseOptions: this.databaseOptions,
|
|
105
109
|
initData: import_globals.default.getInstance().toJSON()
|
|
106
110
|
},
|
|
107
|
-
env:
|
|
108
|
-
...process.env,
|
|
109
|
-
NODE_OPTIONS: maxOldSpaceSize
|
|
110
|
-
}
|
|
111
|
+
env: workerEnv
|
|
111
112
|
});
|
|
112
113
|
} else {
|
|
113
114
|
worker = new import_node_worker_threads.Worker(import_node_path.default.resolve(__dirname, "../../worker-starter.js"), {
|
|
@@ -117,10 +118,7 @@ const _WorkerManager = class _WorkerManager {
|
|
|
117
118
|
databaseOptions: this.databaseOptions,
|
|
118
119
|
initData: import_globals.default.getInstance().toJSON()
|
|
119
120
|
},
|
|
120
|
-
env:
|
|
121
|
-
...process.env,
|
|
122
|
-
NODE_OPTIONS: maxOldSpaceSize
|
|
123
|
-
}
|
|
121
|
+
env: workerEnv
|
|
124
122
|
});
|
|
125
123
|
}
|
|
126
124
|
await new Promise((resolve, reject) => {
|
|
@@ -75,7 +75,7 @@ class WorkerWebController {
|
|
|
75
75
|
__runInitializers(_init, 5, this);
|
|
76
76
|
}
|
|
77
77
|
async info(ctx, next) {
|
|
78
|
-
const app = ctx.
|
|
78
|
+
const app = ctx.tego;
|
|
79
79
|
if (!app.worker) {
|
|
80
80
|
ctx.body = {
|
|
81
81
|
preset: 0,
|
|
@@ -103,7 +103,7 @@ class WorkerWebController {
|
|
|
103
103
|
if (count < 0) {
|
|
104
104
|
ctx.throw(400, ctx.t("Invalid worker count", { ns: import_constants.NAMESPACE }));
|
|
105
105
|
}
|
|
106
|
-
const app = ctx.
|
|
106
|
+
const app = ctx.tego;
|
|
107
107
|
const countMax = app.name === "main" ? import_constants2.WORKER_COUNT_MAX : import_constants2.WORKER_COUNT_MAX_SUB;
|
|
108
108
|
if (count > countMax) {
|
|
109
109
|
ctx.throw(400, ctx.t("Too many workers", { ns: import_constants.NAMESPACE }));
|
|
@@ -118,7 +118,7 @@ class WorkerWebController {
|
|
|
118
118
|
return next();
|
|
119
119
|
}
|
|
120
120
|
async restartAllForcely(ctx, next) {
|
|
121
|
-
const app = ctx.
|
|
121
|
+
const app = ctx.tego;
|
|
122
122
|
await app.worker.restartAllForcely();
|
|
123
123
|
ctx.body = {
|
|
124
124
|
success: true
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-worker-thread",
|
|
3
3
|
"displayName": "Worker thread",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"description": "Worker thread for executing time-consuming tasks",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Workflow"
|
|
8
8
|
],
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@tachybase/globals": "1.
|
|
12
|
-
"@tachybase/loader": "1.
|
|
13
|
-
"@tachybase/schema": "1.
|
|
14
|
-
"@tachybase/test": "1.
|
|
15
|
-
"@tego/client": "1.
|
|
16
|
-
"@tego/server": "1.
|
|
11
|
+
"@tachybase/globals": "1.6.0-alpha.9",
|
|
12
|
+
"@tachybase/loader": "1.6.0-alpha.9",
|
|
13
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
14
|
+
"@tachybase/test": "1.6.0-alpha.9",
|
|
15
|
+
"@tego/client": "1.6.0-alpha.9",
|
|
16
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
17
17
|
"antd": "5.22.5",
|
|
18
18
|
"dayjs": "1.11.13",
|
|
19
19
|
"tsx": "4.20.3",
|
|
20
|
-
"@tachybase/module-collection": "1.
|
|
21
|
-
"@tachybase/client": "1.
|
|
22
|
-
"@tachybase/module-user": "1.
|
|
20
|
+
"@tachybase/module-collection": "1.6.1",
|
|
21
|
+
"@tachybase/client": "1.6.1",
|
|
22
|
+
"@tachybase/module-user": "1.6.1"
|
|
23
23
|
},
|
|
24
24
|
"description.zh-CN": "工作线程,用于执行耗时任务",
|
|
25
25
|
"displayName.zh-CN": "工作线程",
|