bm2 1.0.13 → 1.0.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bm2",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
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/index.ts",
6
6
  "module": "src/index.ts",
package/src/daemon.ts CHANGED
@@ -78,8 +78,8 @@ const handleServerRequests = async (req: Request) => {
78
78
  };
79
79
 
80
80
  const serverOptions = {
81
- unix: DAEMON_SOCKET,
82
- fetch: handleServerRequests
81
+ unix: DAEMON_SOCKET,
82
+ fetch: handleServerRequests
83
83
  }
84
84
 
85
85
  async function handleMessage(msg: DaemonMessage): Promise<DaemonResponse> {
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ import type {
41
41
  } from "./types";
42
42
  import Table from "cli-table3";
43
43
  import { statusColor } from "./colors";
44
- import { liveWatchProcess, printProcessTable, watchProcesses } from "./process-table";
44
+ import { liveWatchProcess, printProcessTable } from "./process-table";
45
45
 
46
46
  // ---------------------------------------------------------------------------
47
47
  // Ensure directory structure exists
@@ -95,35 +95,39 @@ async function startDaemon(): Promise<void> {
95
95
 
96
96
  async function sendToDaemon(msg: DaemonMessage): Promise<DaemonResponse> {
97
97
 
98
- //await startDaemon();
98
+ //start the daemon
99
+ await startDaemon();
99
100
 
100
- let res;
101
+ let res;
101
102
 
102
- try {
103
-
104
- res = await fetch("http://localhost/command", {
105
- unix: DAEMON_SOCKET,
106
- method: "POST",
107
- headers: {
108
- "Content-Type": "application/json",
109
- },
110
- body: JSON.stringify(msg),
111
- });
112
-
113
- if (!res.ok) {
114
- throw new Error(`Daemon error: ${res.status}`);
115
- }
116
-
117
- const resJson: DaemonResponse = await res.json() as DaemonResponse;
118
-
119
- return resJson;
103
+ try {
120
104
 
121
- } catch (e: any) {
122
- console.log("Results returned: " + await res?.text())
123
- console.log()
124
- console.log("sendToDaemon#Error:", e, e.stack)
125
- return { type: "error", error: "Fetch Error", success: false }
105
+ const uri = `http://localhost/command`
106
+
107
+ res = await fetch(uri, {
108
+ unix: DAEMON_SOCKET,
109
+ method: "POST",
110
+ headers: {
111
+ "Content-Type": "application/json",
112
+ },
113
+ body: JSON.stringify(msg),
114
+ });
115
+
116
+ if (!res.ok) {
117
+ throw new Error(`Daemon error: ${res.status}`);
126
118
  }
119
+
120
+ const resJson: DaemonResponse = await res.json() as DaemonResponse;
121
+
122
+ return resJson;
123
+
124
+ } catch (e: any) {
125
+ console.log("Results returned: " + await res?.text())
126
+ console.log()
127
+ console.log("sendToDaemon#Error:", e, e.stack)
128
+ return { type: "error", error: "Fetch Error", success: false }
129
+ }
130
+
127
131
  }
128
132
 
129
133
 
@@ -319,7 +323,8 @@ async function cmdStart(args: string[]) {
319
323
  if (
320
324
  ext === ".json" ||
321
325
  scriptOrConfig.includes("ecosystem") ||
322
- scriptOrConfig.includes("bm2.config")
326
+ scriptOrConfig.includes("bm2.config") ||
327
+ scriptOrConfig.includes("pm2.config")
323
328
  ) {
324
329
  const config = await loadEcosystemConfig(scriptOrConfig);
325
330
  const res = await sendToDaemon({ type: "ecosystem", data: config });