bm2 1.0.27 → 1.0.29
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/process-manager.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bm2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"description": "A blazing-fast, full-featured process manager built entirely on Bun native APIs. The modern PM2 replacement — zero Node.js dependencies, pure Bun performance.",
|
|
5
5
|
"main": "src/api.ts",
|
|
6
6
|
"module": "src/api.ts",
|
package/src/process-manager.ts
CHANGED
|
@@ -35,9 +35,8 @@
|
|
|
35
35
|
DEFAULT_RESTART_DELAY,
|
|
36
36
|
DEFAULT_LOG_MAX_SIZE,
|
|
37
37
|
DEFAULT_LOG_RETAIN,
|
|
38
|
-
} from "./constants";
|
|
38
|
+
} from "./constants";
|
|
39
39
|
import path from "path";
|
|
40
|
-
|
|
41
40
|
|
|
42
41
|
export class ProcessManager {
|
|
43
42
|
private processes: Map<number, ProcessContainer> = new Map();
|
|
@@ -63,12 +62,18 @@ import path from "path";
|
|
|
63
62
|
const resolvedInstances = this.clusterManager.resolveInstances(options.instances);
|
|
64
63
|
const isCluster = options.execMode === "cluster" || resolvedInstances > 1;
|
|
65
64
|
const states: ProcessState[] = [];
|
|
65
|
+
|
|
66
|
+
options.script = path.isAbsolute(options.script)
|
|
67
|
+
? options.script
|
|
68
|
+
: path.resolve(process.cwd(), options.script);
|
|
69
|
+
|
|
70
|
+
if (!(await Bun.file(options.script).exists())) {
|
|
71
|
+
throw new Error(`Script not found: ${options.script}`);
|
|
72
|
+
}
|
|
66
73
|
|
|
67
74
|
if (isCluster) {
|
|
68
75
|
// In cluster mode, each instance is a separate container
|
|
69
76
|
for (let i = 0; i < resolvedInstances; i++) {
|
|
70
|
-
|
|
71
|
-
options.script = path.resolve(options.script);
|
|
72
77
|
|
|
73
78
|
const id = this.nextId++;
|
|
74
79
|
const baseName = options.name || options.script.split("/").pop()?.replace(/\.\w+$/, "") || `app-${id}`;
|
|
@@ -81,7 +86,7 @@ import path from "path";
|
|
|
81
86
|
config,
|
|
82
87
|
this.logManager,
|
|
83
88
|
this.clusterManager,
|
|
84
|
-
this.healthChecker,
|
|
89
|
+
this.healthChecker,
|
|
85
90
|
this.cronManager
|
|
86
91
|
);
|
|
87
92
|
|
|
@@ -117,15 +122,10 @@ import path from "path";
|
|
|
117
122
|
instances: number,
|
|
118
123
|
workerIndex: number
|
|
119
124
|
): ProcessDescription {
|
|
120
|
-
|
|
121
|
-
const script = path.isAbsolute(options.script)
|
|
122
|
-
? options.script
|
|
123
|
-
: path.resolve(process.cwd(), options.script);
|
|
124
|
-
|
|
125
125
|
return {
|
|
126
126
|
id,
|
|
127
127
|
name,
|
|
128
|
-
script,
|
|
128
|
+
script: options.script,
|
|
129
129
|
args: options.args || [],
|
|
130
130
|
cwd: options.cwd || process.cwd(),
|
|
131
131
|
env: {
|