@eggjs/cluster 4.0.0-beta.34 → 4.0.0-beta.36
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/agent_worker.d.ts +1 -1
- package/dist/agent_worker.js +50 -65
- package/dist/app_worker.d.ts +1 -1
- package/dist/app_worker.js +127 -165
- package/dist/error/ClusterAgentWorkerError.d.ts +12 -9
- package/dist/error/ClusterAgentWorkerError.js +22 -19
- package/dist/error/ClusterWorkerExceptionError.d.ts +9 -6
- package/dist/error/ClusterWorkerExceptionError.js +17 -14
- package/dist/index.d.ts +20 -15
- package/dist/index.js +20 -16
- package/dist/master.d.ts +89 -86
- package/dist/master.js +425 -556
- package/dist/utils/messenger.d.ts +93 -89
- package/dist/utils/messenger.js +143 -178
- package/dist/utils/mode/base/agent.d.ts +42 -35
- package/dist/utils/mode/base/agent.js +63 -65
- package/dist/utils/mode/base/app.d.ts +53 -45
- package/dist/utils/mode/base/app.js +77 -80
- package/dist/utils/mode/impl/process/agent.d.ts +20 -16
- package/dist/utils/mode/impl/process/agent.js +95 -105
- package/dist/utils/mode/impl/process/app.d.ts +23 -19
- package/dist/utils/mode/impl/process/app.js +116 -118
- package/dist/utils/mode/impl/worker_threads/agent.d.ts +20 -16
- package/dist/utils/mode/impl/worker_threads/agent.js +78 -85
- package/dist/utils/mode/impl/worker_threads/app.d.ts +28 -24
- package/dist/utils/mode/impl/worker_threads/app.js +128 -137
- package/dist/utils/options.d.ts +79 -76
- package/dist/utils/options.js +55 -80
- package/dist/utils/terminate.js +50 -70
- package/dist/utils/worker_manager.d.ts +28 -24
- package/dist/utils/worker_manager.js +68 -74
- package/package.json +33 -34
- package/dist/error/index.d.ts +0 -2
- package/dist/error/index.js +0 -3
- package/dist/utils/terminate.d.ts +0 -6
package/dist/agent_worker.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/agent_worker.js
CHANGED
|
@@ -1,70 +1,55 @@
|
|
|
1
|
-
import { debuglog } from 'node:util';
|
|
2
|
-
import { EggConsoleLogger as ConsoleLogger } from 'egg-logger';
|
|
3
|
-
import { importModule } from '@eggjs/utils';
|
|
4
|
-
import { BaseAgentWorker } from "./utils/mode/base/agent.js";
|
|
5
|
-
import { AgentThreadWorker } from "./utils/mode/impl/worker_threads/agent.js";
|
|
6
1
|
import { AgentProcessWorker } from "./utils/mode/impl/process/agent.js";
|
|
7
|
-
|
|
2
|
+
import { AgentThreadWorker } from "./utils/mode/impl/worker_threads/agent.js";
|
|
3
|
+
import { debuglog } from "node:util";
|
|
4
|
+
import { EggConsoleLogger } from "egg-logger";
|
|
5
|
+
import { importModule } from "@eggjs/utils";
|
|
6
|
+
|
|
7
|
+
//#region src/agent_worker.ts
|
|
8
|
+
const debug = debuglog("egg/cluster/agent_worker");
|
|
8
9
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
* agent worker is child_process forked by master.
|
|
11
|
+
*
|
|
12
|
+
* agent worker only exit in two cases:
|
|
13
|
+
* - receive signal SIGTERM, exit code 0 (exit gracefully)
|
|
14
|
+
* - receive disconnect event, exit code 110 (maybe master exit in accident)
|
|
15
|
+
*/
|
|
15
16
|
async function main() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
consoleLogger.error('[agent_worker] start error, exiting with code:1');
|
|
51
|
-
AgentWorker.kill();
|
|
52
|
-
}
|
|
53
|
-
agent.ready((err) => {
|
|
54
|
-
// don't send started message to master when start error
|
|
55
|
-
if (err) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
agent.removeListener('error', startErrorHandler);
|
|
59
|
-
AgentWorker.send({ action: 'agent-start', to: 'master' });
|
|
60
|
-
});
|
|
61
|
-
// exit if agent start error
|
|
62
|
-
agent.once('error', startErrorHandler);
|
|
63
|
-
AgentWorker.gracefulExit({
|
|
64
|
-
logger: consoleLogger,
|
|
65
|
-
label: 'agent_worker',
|
|
66
|
-
beforeExit: () => agent.close(),
|
|
67
|
-
});
|
|
17
|
+
const options = JSON.parse(process.argv[2]);
|
|
18
|
+
if (options.require) for (const mod of options.require) await importModule(mod, { paths: [options.baseDir] });
|
|
19
|
+
let AgentWorker;
|
|
20
|
+
if (options.startMode === "worker_threads") AgentWorker = AgentThreadWorker;
|
|
21
|
+
else AgentWorker = AgentProcessWorker;
|
|
22
|
+
const consoleLogger = new EggConsoleLogger({ level: process.env.EGG_AGENT_WORKER_LOGGER_LEVEL });
|
|
23
|
+
const { Agent } = await importModule(options.framework, { paths: [options.baseDir] });
|
|
24
|
+
debug("new Agent with options %j", options);
|
|
25
|
+
let agent;
|
|
26
|
+
try {
|
|
27
|
+
agent = new Agent(options);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
consoleLogger.error(err);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
function startErrorHandler(err) {
|
|
33
|
+
consoleLogger.error(err);
|
|
34
|
+
consoleLogger.error("[agent_worker] start error, exiting with code:1");
|
|
35
|
+
AgentWorker.kill();
|
|
36
|
+
}
|
|
37
|
+
agent.ready((err) => {
|
|
38
|
+
if (err) return;
|
|
39
|
+
agent.removeListener("error", startErrorHandler);
|
|
40
|
+
AgentWorker.send({
|
|
41
|
+
action: "agent-start",
|
|
42
|
+
to: "master"
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
agent.once("error", startErrorHandler);
|
|
46
|
+
AgentWorker.gracefulExit({
|
|
47
|
+
logger: consoleLogger,
|
|
48
|
+
label: "agent_worker",
|
|
49
|
+
beforeExit: () => agent.close()
|
|
50
|
+
});
|
|
68
51
|
}
|
|
69
52
|
main();
|
|
70
|
-
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { };
|
package/dist/app_worker.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|
package/dist/app_worker.js
CHANGED
|
@@ -1,169 +1,131 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { createServer as createHttpServer } from 'node:http';
|
|
3
|
-
import { createServer as createHttpsServer } from 'node:https';
|
|
4
|
-
import { debuglog } from 'node:util';
|
|
5
|
-
import { EggConsoleLogger as ConsoleLogger } from 'egg-logger';
|
|
6
|
-
import { importModule } from '@eggjs/utils';
|
|
7
|
-
import { BaseAppWorker } from "./utils/mode/base/app.js";
|
|
8
|
-
import { AppThreadWorker } from "./utils/mode/impl/worker_threads/app.js";
|
|
9
1
|
import { AppProcessWorker } from "./utils/mode/impl/process/app.js";
|
|
10
|
-
|
|
2
|
+
import { AppThreadWorker } from "./utils/mode/impl/worker_threads/app.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { debuglog } from "node:util";
|
|
5
|
+
import { EggConsoleLogger } from "egg-logger";
|
|
6
|
+
import { importModule } from "@eggjs/utils";
|
|
7
|
+
import { createServer } from "node:http";
|
|
8
|
+
import { createServer as createServer$1 } from "node:https";
|
|
9
|
+
|
|
10
|
+
//#region src/app_worker.ts
|
|
11
|
+
const debug = debuglog("egg/cluster/app_worker");
|
|
11
12
|
async function main() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
exitProcess();
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const args = [port];
|
|
130
|
-
if (listenConfig.hostname) {
|
|
131
|
-
args.push(listenConfig.hostname);
|
|
132
|
-
}
|
|
133
|
-
debug('listen options %j', args);
|
|
134
|
-
server.listen(...args);
|
|
135
|
-
}
|
|
136
|
-
if (debugPortServer) {
|
|
137
|
-
debug('listen on debug port: %s', debugPort);
|
|
138
|
-
debugPortServer.listen(debugPort);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
server.once('listening', () => {
|
|
142
|
-
let address = server.address() || { port };
|
|
143
|
-
if (typeof address === 'string') {
|
|
144
|
-
// https://nodejs.org/api/cluster.html#cluster_event_listening_1
|
|
145
|
-
// Unix domain socket
|
|
146
|
-
address = {
|
|
147
|
-
address,
|
|
148
|
-
addressType: -1,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
debug('[app_worker:%s] listening at %j', process.pid, address);
|
|
152
|
-
AppWorker.send({
|
|
153
|
-
to: 'master',
|
|
154
|
-
action: 'app-start',
|
|
155
|
-
data: {
|
|
156
|
-
address,
|
|
157
|
-
workerId: AppWorker.workerId,
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
AppWorker.gracefulExit({
|
|
163
|
-
logger: consoleLogger,
|
|
164
|
-
label: 'app_worker',
|
|
165
|
-
beforeExit: () => app.close(),
|
|
166
|
-
});
|
|
13
|
+
const options = JSON.parse(process.argv[2]);
|
|
14
|
+
if (options.require) for (const mod of options.require) await importModule(mod, { paths: [options.baseDir] });
|
|
15
|
+
let AppWorker;
|
|
16
|
+
if (options.startMode === "worker_threads") AppWorker = AppThreadWorker;
|
|
17
|
+
else AppWorker = AppProcessWorker;
|
|
18
|
+
const consoleLogger = new EggConsoleLogger({ level: process.env.EGG_APP_WORKER_LOGGER_LEVEL });
|
|
19
|
+
const { Application } = await importModule(options.framework, { paths: [options.baseDir] });
|
|
20
|
+
debug("[app_worker:%s] new Application with options %j", process.pid, options);
|
|
21
|
+
let app;
|
|
22
|
+
try {
|
|
23
|
+
app = new Application(options);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
consoleLogger.error(err);
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
app.ready(startServer);
|
|
29
|
+
function exitProcess() {
|
|
30
|
+
AppWorker.kill();
|
|
31
|
+
}
|
|
32
|
+
app.once("startTimeout", startTimeoutHandler);
|
|
33
|
+
function startTimeoutHandler() {
|
|
34
|
+
consoleLogger.error("[app_worker] start timeout, exiting with code:1");
|
|
35
|
+
exitProcess();
|
|
36
|
+
}
|
|
37
|
+
function startServer(err) {
|
|
38
|
+
if (err) {
|
|
39
|
+
consoleLogger.error(err);
|
|
40
|
+
consoleLogger.error("[app_worker] start error, exiting with code:1");
|
|
41
|
+
exitProcess();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const clusterConfig = app.config.cluster ?? {};
|
|
45
|
+
const listenConfig = clusterConfig.listen ?? {};
|
|
46
|
+
const httpsOptions = {
|
|
47
|
+
...clusterConfig.https,
|
|
48
|
+
...options.https
|
|
49
|
+
};
|
|
50
|
+
const port = app.options.port = options.port || listenConfig.port;
|
|
51
|
+
const debugPort = options.debugPort;
|
|
52
|
+
const protocol = httpsOptions.key && httpsOptions.cert ? "https" : "http";
|
|
53
|
+
debug("[app_worker:%s] listenConfig: %j, real port: %o, protocol: %o, debugPort: %o", process.pid, listenConfig, port, protocol, debugPort);
|
|
54
|
+
AppWorker.send({
|
|
55
|
+
to: "master",
|
|
56
|
+
action: "realport",
|
|
57
|
+
data: {
|
|
58
|
+
port,
|
|
59
|
+
protocol
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
app.removeListener("startTimeout", startTimeoutHandler);
|
|
63
|
+
let server;
|
|
64
|
+
let debugPortServer;
|
|
65
|
+
if (protocol === "https") {
|
|
66
|
+
httpsOptions.key = fs.readFileSync(httpsOptions.key);
|
|
67
|
+
httpsOptions.cert = fs.readFileSync(httpsOptions.cert);
|
|
68
|
+
httpsOptions.ca = httpsOptions.ca && fs.readFileSync(httpsOptions.ca);
|
|
69
|
+
server = createServer$1(httpsOptions, app.callback());
|
|
70
|
+
if (debugPort) debugPortServer = createServer(app.callback());
|
|
71
|
+
} else {
|
|
72
|
+
server = createServer(app.callback());
|
|
73
|
+
if (debugPort) debugPortServer = server;
|
|
74
|
+
}
|
|
75
|
+
server.once("error", (err$1) => {
|
|
76
|
+
consoleLogger.error("[app_worker] server got error: %s, code: %s", err$1.message, err$1.code);
|
|
77
|
+
exitProcess();
|
|
78
|
+
});
|
|
79
|
+
app.emit("server", server);
|
|
80
|
+
if (options.sticky && options.stickyWorkerPort) {
|
|
81
|
+
server.listen(options.stickyWorkerPort, "127.0.0.1");
|
|
82
|
+
AppWorker.on("message", (message, connection) => {
|
|
83
|
+
if (message !== "sticky-session:connection") return;
|
|
84
|
+
server.emit("connection", connection);
|
|
85
|
+
connection.resume();
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
if (listenConfig.path) server.listen(listenConfig.path);
|
|
89
|
+
else {
|
|
90
|
+
if (typeof port !== "number") {
|
|
91
|
+
consoleLogger.error("[app_worker:%s] port should be number, but got %s(%s)", process.pid, port, typeof port);
|
|
92
|
+
exitProcess();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const args = [port];
|
|
96
|
+
if (listenConfig.hostname) args.push(listenConfig.hostname);
|
|
97
|
+
debug("listen options %j", args);
|
|
98
|
+
server.listen(...args);
|
|
99
|
+
}
|
|
100
|
+
if (debugPortServer) {
|
|
101
|
+
debug("listen on debug port: %s", debugPort);
|
|
102
|
+
debugPortServer.listen(debugPort);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
server.once("listening", () => {
|
|
106
|
+
let address = server.address() || { port };
|
|
107
|
+
if (typeof address === "string") address = {
|
|
108
|
+
address,
|
|
109
|
+
addressType: -1
|
|
110
|
+
};
|
|
111
|
+
debug("[app_worker:%s] listening at %j", process.pid, address);
|
|
112
|
+
AppWorker.send({
|
|
113
|
+
to: "master",
|
|
114
|
+
action: "app-start",
|
|
115
|
+
data: {
|
|
116
|
+
address,
|
|
117
|
+
workerId: AppWorker.workerId
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
AppWorker.gracefulExit({
|
|
123
|
+
logger: consoleLogger,
|
|
124
|
+
label: "app_worker",
|
|
125
|
+
beforeExit: () => app.close()
|
|
126
|
+
});
|
|
167
127
|
}
|
|
168
128
|
main();
|
|
169
|
-
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/error/ClusterAgentWorkerError.d.ts
|
|
2
|
+
declare class ClusterAgentWorkerError extends Error {
|
|
3
|
+
id: number;
|
|
4
|
+
/**
|
|
5
|
+
* pid in process mode
|
|
6
|
+
* tid in worker_threads mode
|
|
7
|
+
*/
|
|
8
|
+
workerId: number;
|
|
9
|
+
status: string;
|
|
10
|
+
constructor(id: number, workerId: number, status: string, error: Error);
|
|
10
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ClusterAgentWorkerError };
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
1
|
+
//#region src/error/ClusterAgentWorkerError.ts
|
|
2
|
+
var ClusterAgentWorkerError = class extends Error {
|
|
3
|
+
id;
|
|
4
|
+
/**
|
|
5
|
+
* pid in process mode
|
|
6
|
+
* tid in worker_threads mode
|
|
7
|
+
*/
|
|
8
|
+
workerId;
|
|
9
|
+
status;
|
|
10
|
+
constructor(id, workerId, status, error) {
|
|
11
|
+
const message = `Got agent worker error: ${error.message}`;
|
|
12
|
+
super(message, { cause: error });
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
this.id = id;
|
|
15
|
+
this.workerId = workerId;
|
|
16
|
+
this.status = status;
|
|
17
|
+
Error.captureStackTrace(this, this.constructor);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ClusterAgentWorkerError };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region src/error/ClusterWorkerExceptionError.d.ts
|
|
2
|
+
declare class ClusterWorkerExceptionError extends Error {
|
|
3
|
+
count: {
|
|
4
|
+
agent: number;
|
|
5
|
+
worker: number;
|
|
6
|
+
};
|
|
7
|
+
constructor(agent: number, worker: number);
|
|
7
8
|
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ClusterWorkerExceptionError };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
1
|
+
//#region src/error/ClusterWorkerExceptionError.ts
|
|
2
|
+
var ClusterWorkerExceptionError = class extends Error {
|
|
3
|
+
count;
|
|
4
|
+
constructor(agent, worker) {
|
|
5
|
+
const message = `[master] ${agent} agent and ${worker} worker(s) alive, exit to avoid unknown state`;
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = this.constructor.name;
|
|
8
|
+
this.count = {
|
|
9
|
+
agent,
|
|
10
|
+
worker
|
|
11
|
+
};
|
|
12
|
+
Error.captureStackTrace(this, this.constructor);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ClusterWorkerExceptionError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ClusterHTTPSSecureOptions, ClusterOptions, ClusterStartMode } from "./utils/options.js";
|
|
2
|
+
import { Master, MasterOptions } from "./master.js";
|
|
3
|
+
import { ClusterAgentWorkerError } from "./error/ClusterAgentWorkerError.js";
|
|
4
|
+
import { ClusterWorkerExceptionError } from "./error/ClusterWorkerExceptionError.js";
|
|
5
|
+
|
|
6
|
+
//#region src/index.d.ts
|
|
7
|
+
|
|
3
8
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
* cluster start flow:
|
|
10
|
+
*
|
|
11
|
+
* [startCluster] -> master -> agent_worker -> new [Agent] -> agentWorkerLoader
|
|
12
|
+
* `-> app_worker -> new [Application] -> appWorkerLoader
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
10
15
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
16
|
+
* start egg app
|
|
17
|
+
* @function Egg#startCluster
|
|
18
|
+
* @param {Object} options {@link Master}
|
|
19
|
+
*/
|
|
20
|
+
declare function startCluster(options: ClusterOptions): Promise<void>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ClusterAgentWorkerError, type ClusterHTTPSSecureOptions, type ClusterOptions, type ClusterStartMode, ClusterWorkerExceptionError, Master, type MasterOptions, startCluster };
|