bm2 1.0.3 → 1.0.5
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/package.json +1 -1
- package/src/constants.ts +6 -2
- package/src/daemon.ts +26 -44
- package/src/index.ts +740 -270
- package/src/process-manager.ts +43 -43
package/src/process-manager.ts
CHANGED
|
@@ -57,49 +57,49 @@
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async start(options: StartOptions): Promise<ProcessState[]> {
|
|
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
|
-
|
|
60
|
+
|
|
61
|
+
const resolvedInstances = this.clusterManager.resolveInstances(options.instances);
|
|
62
|
+
const isCluster = options.execMode === "cluster" || resolvedInstances > 1;
|
|
63
|
+
const states: ProcessState[] = [];
|
|
64
|
+
|
|
65
|
+
if (isCluster) {
|
|
66
|
+
// In cluster mode, each instance is a separate container
|
|
67
|
+
for (let i = 0; i < resolvedInstances; i++) {
|
|
68
|
+
|
|
69
|
+
const id = this.nextId++;
|
|
70
|
+
const baseName = options.name || options.script.split("/").pop()?.replace(/\.\w+$/, "") || `app-${id}`;
|
|
71
|
+
const name = resolvedInstances > 1 ? `${baseName}-${i}` : baseName;
|
|
72
|
+
|
|
73
|
+
const config = this.buildConfig(id, name, options, resolvedInstances, i);
|
|
74
|
+
|
|
75
|
+
const container = new ProcessContainer(
|
|
76
|
+
id, config, this.logManager, this.clusterManager,
|
|
77
|
+
this.healthChecker, this.cronManager
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
this.processes.set(id, container);
|
|
81
|
+
await container.start();
|
|
82
|
+
states.push(container.getState());
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
const id = this.nextId++;
|
|
86
|
+
const name =
|
|
87
|
+
options.name ||
|
|
88
|
+
options.script.split("/").pop()?.replace(/\.\w+$/, "") ||
|
|
89
|
+
`app-${id}`;
|
|
90
|
+
|
|
91
|
+
const config = this.buildConfig(id, name, options, 1, 0);
|
|
92
|
+
const container = new ProcessContainer(
|
|
93
|
+
id, config, this.logManager, this.clusterManager,
|
|
94
|
+
this.healthChecker, this.cronManager
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
this.processes.set(id, container);
|
|
98
|
+
await container.start();
|
|
99
|
+
states.push(container.getState());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return states;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
private buildConfig(
|