bm2 1.0.36 → 1.0.37

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/README.md CHANGED
@@ -135,7 +135,7 @@ curl -fsSL https://bun.sh/install | bash
135
135
  ### From Source
136
136
 
137
137
  ```
138
- git clone https://github.com/aspect-dev/bm2.git
138
+ git clone https://github.com/bun-bm2/bm2.git
139
139
  cd bm2
140
140
  bun install
141
141
  bun link
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm2",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
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/index.ts CHANGED
@@ -53,6 +53,8 @@ await ensureDirs();
53
53
  // ---------------------------------------------------------------------------
54
54
 
55
55
  class BM2CLI {
56
+
57
+ noDaemon = false;
56
58
 
57
59
  // -------------------------------------------------------------------------
58
60
  // Daemon helpers
@@ -120,6 +122,12 @@ class BM2CLI {
120
122
  }
121
123
 
122
124
  async sendToDaemon(msg: DaemonMessage): Promise<DaemonResponse> {
125
+
126
+
127
+ if (this.noDaemon) {
128
+ return this.callDaemonCmd(msg)
129
+ }
130
+
123
131
  await this.startDaemon();
124
132
 
125
133
  let res;
@@ -180,9 +188,15 @@ class BM2CLI {
180
188
  }
181
189
 
182
190
  const cwd = path.dirname(abs);
191
+
192
+ if (config.noDaemon) {
193
+ this.noDaemon = config.noDaemon;
194
+ }
183
195
 
184
196
  config.apps = config.apps.map((i) => {
185
- if ((i.cwd || "").trim() === "") i.cwd = cwd;
197
+ if ((i.cwd || "").trim() === "") {
198
+ i.cwd = cwd;
199
+ }
186
200
  return i;
187
201
  });
188
202
 
@@ -202,7 +216,8 @@ class BM2CLI {
202
216
  // -------------------------------------------------------------------------
203
217
 
204
218
  parseStartFlags(args: string[]): StartOptions {
205
- const opts: StartOptions = { script: "", noDaemon: false };
219
+
220
+ const opts: StartOptions = { script: "" };
206
221
 
207
222
  let i = 0;
208
223
  let scriptResolved = false;
@@ -275,10 +290,6 @@ class BM2CLI {
275
290
  case "--no-autorestart":
276
291
  opts.autorestart = false;
277
292
  break;
278
- case "--no-daemon":
279
- case "-d":
280
- opts.noDaemon = true;
281
- break;
282
293
  case "--env": {
283
294
  const envPair = args[++i]!;
284
295
  const eqIdx = envPair.indexOf("=");
@@ -369,6 +380,7 @@ class BM2CLI {
369
380
  // -------------------------------------------------------------------------
370
381
 
371
382
  async cmdStart(args: string[]) {
383
+
372
384
  if (args.length === 0) {
373
385
  console.error(colorize("Usage: bm2 start <script|config> [options]", "red"));
374
386
  process.exit(1);
@@ -391,42 +403,47 @@ class BM2CLI {
391
403
  firstPositional.includes("bm2.config") ||
392
404
  firstPositional.includes("pm2.config")
393
405
  ) {
406
+
394
407
  const config = await this.loadEcosystemConfig(firstPositional);
395
408
  const res = await this.sendToDaemon({ type: "ecosystem", data: config });
409
+
396
410
  if (!res.success) {
397
411
  console.error(colorize(`Error: ${res.error}`, "red"));
398
412
  process.exit(1);
399
413
  }
414
+
400
415
  printProcessTable(res.data);
401
- return;
402
- }
403
-
404
- // Parse all args — parseStartFlags finds the script itself
405
- const opts = this.parseStartFlags(args);
406
-
407
- if (!opts.script) {
408
- console.error(colorize("Error: no script specified", "red"));
409
- process.exit(1);
410
- }
411
-
412
- opts.script = resolve(opts.script);
413
- if (!opts.cwd) opts.cwd = path.dirname(opts.script);
414
-
415
- const noDaemon = opts.noDaemon;
416
-
417
- const res = noDaemon
418
- ? await this.callDaemonCmd({ type: "start", data: opts })
419
- : await this.sendToDaemon({ type: "start", data: opts });
420
-
421
- if (!res.success) {
422
- console.error(colorize(`Error: ${res.error}`, "red"));
423
- process.exit(1);
424
- }
425
-
426
- printProcessTable(res.data);
416
+
417
+ if (this.noDaemon) {
418
+ await new Promise(() => {});
419
+ }
420
+
421
+ } else {
427
422
 
428
- if (noDaemon) {
429
- await new Promise(() => {});
423
+ // Parse all args — parseStartFlags finds the script itself
424
+ const opts = this.parseStartFlags(args);
425
+
426
+ if (!opts.script) {
427
+ console.error(colorize("Error: no script specified", "red"));
428
+ process.exit(1);
429
+ }
430
+
431
+ opts.script = resolve(opts.script);
432
+
433
+ if (!opts.cwd) opts.cwd = path.dirname(opts.script);
434
+
435
+ const res = await this.sendToDaemon({ type: "start", data: opts });
436
+
437
+ if (!res.success) {
438
+ console.error(colorize(`Error: ${res.error}`, "red"));
439
+ process.exit(1);
440
+ }
441
+
442
+ printProcessTable(res.data);
443
+
444
+ if (this.noDaemon) {
445
+ await new Promise(() => {});
446
+ }
430
447
  }
431
448
  }
432
449
 
@@ -1044,6 +1061,8 @@ class BM2CLI {
1044
1061
  async run(argv: string[]) {
1045
1062
  const command = argv[0];
1046
1063
  const commandArgs = argv.slice(1);
1064
+
1065
+ this.noDaemon = argv.includes("--no-daemon") || argv.includes("-d");
1047
1066
 
1048
1067
  switch (command) {
1049
1068
  case "start":
package/src/types.ts CHANGED
@@ -124,7 +124,6 @@ export interface StartOptions {
124
124
  instances?: number;
125
125
  execMode?: ExecMode;
126
126
  autorestart?: boolean;
127
- noDaemon?: boolean;
128
127
  maxRestarts?: number;
129
128
  minUptime?: number;
130
129
  maxMemoryRestart?: string | number;
@@ -156,6 +155,7 @@ export interface StartOptions {
156
155
 
157
156
  export interface EcosystemConfig {
158
157
  apps: StartOptions[];
158
+ noDaemon?: boolean;
159
159
  deploy?: Record<string, DeployConfig>;
160
160
  }
161
161