@workermill/agent 0.7.21 → 0.8.0
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/commands/start.js +14 -2
- package/package.json +1 -1
package/dist/commands/start.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import { totalmem } from "os";
|
|
11
11
|
import { spawn } from "child_process";
|
|
12
|
-
import { writeFileSync, existsSync, unlinkSync, openSync } from "fs";
|
|
12
|
+
import { writeFileSync, existsSync, unlinkSync, openSync, createWriteStream } from "fs";
|
|
13
13
|
import { AGENT_VERSION } from "../version.js";
|
|
14
14
|
import { loadConfigFromFile, checkPrerequisites, getSystemInfo, getPidFile, getLogFile, getConfigFile, } from "../config.js";
|
|
15
15
|
import { startAgent } from "../index.js";
|
|
@@ -81,7 +81,19 @@ export async function startCommand(options) {
|
|
|
81
81
|
}
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
// Foreground mode
|
|
84
|
+
// Foreground mode — tee stdout/stderr to log file so `workermill-agent logs` works
|
|
85
|
+
const logFile = getLogFile();
|
|
86
|
+
const logStream = createWriteStream(logFile, { flags: "a" });
|
|
87
|
+
const origStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
88
|
+
const origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
89
|
+
process.stdout.write = (chunk, ...args) => {
|
|
90
|
+
logStream.write(chunk);
|
|
91
|
+
return origStdoutWrite(chunk, ...args);
|
|
92
|
+
};
|
|
93
|
+
process.stderr.write = (chunk, ...args) => {
|
|
94
|
+
logStream.write(chunk);
|
|
95
|
+
return origStderrWrite(chunk, ...args);
|
|
96
|
+
};
|
|
85
97
|
console.log();
|
|
86
98
|
console.log(chalk.bold.cyan(" WorkerMill Remote Agent"));
|
|
87
99
|
console.log(chalk.dim(" ─────────────────────────────────────"));
|