Tee applier stdout/stderr to data/applier.log
Writes all console output to a log file from inside the process so logs are always available regardless of how the process is launched. Fixes invisible output when claw redirects stdout to a file that gets overwritten by a second lock-blocked attempt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,12 +6,19 @@ loadEnv(); // load .env before anything else
|
||||
* Reads jobs queue and applies using the appropriate handler per apply_type
|
||||
* Run via cron or manually: node job_applier.mjs [--preview]
|
||||
*/
|
||||
import { existsSync, writeFileSync } from 'fs';
|
||||
import { existsSync, writeFileSync, createWriteStream } from 'fs';
|
||||
import { dirname, resolve } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dir = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Tee all output to a log file so it's always available regardless of how the process is launched
|
||||
const logStream = createWriteStream(resolve(__dir, 'data/applier.log'), { flags: 'w' });
|
||||
const origStdoutWrite = process.stdout.write.bind(process.stdout);
|
||||
const origStderrWrite = process.stderr.write.bind(process.stderr);
|
||||
process.stdout.write = (chunk, ...args) => { logStream.write(chunk); return origStdoutWrite(chunk, ...args); };
|
||||
process.stderr.write = (chunk, ...args) => { logStream.write(chunk); return origStderrWrite(chunk, ...args); };
|
||||
|
||||
import { getJobsByStatus, updateJobStatus, appendLog, loadConfig, isAlreadyApplied } from './lib/queue.mjs';
|
||||
import { acquireLock } from './lib/lock.mjs';
|
||||
import { createBrowser } from './lib/browser.mjs';
|
||||
|
||||
Reference in New Issue
Block a user