Files
MichilisandClaude Opus 5.5 f09445b6ad
ci / check (push) Canceled after 0s
ci / images (push) Canceled after 0s
ci / e2e (push) Canceled after 0s
Initial commit
Paper Sats: design and print paper notes that carry sats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 05:15:30 +00:00

41 lines
1.2 KiB
JavaScript

/**
* Starts the built app for the flows, with the local-only environment. Server output also goes to
* E2E_SERVER_LOG, which the flows scan for secrets.
*/
import { spawn } from 'node:child_process';
import { createWriteStream } from 'node:fs';
import { env } from '../e2e/lib/env.mjs';
const log = process.env.E2E_SERVER_LOG
? createWriteStream(process.env.E2E_SERVER_LOG, { flags: 'a' })
: null;
const child = spawn('pnpm', ['exec', 'next', 'start', '--port', env.PORT], {
env: { ...process.env, ...env },
stdio: ['ignore', 'pipe', 'pipe'],
});
for (const [from, to] of [
[child.stdout, process.stdout],
[child.stderr, process.stderr],
]) {
from.on('data', (chunk) => {
to.write(chunk);
log?.write(chunk);
});
}
// The worker runs too, so the flows see real indexing, usage counts and fee retries.
const worker = spawn('pnpm', ['--filter', '@paper-sats/worker', 'start'], {
env: { ...process.env, ...env },
stdio: ['ignore', 'pipe', 'pipe'],
});
for (const from of [worker.stdout, worker.stderr]) from.on('data', (chunk) => log?.write(chunk));
child.on('exit', (code) => {
worker.kill();
process.exit(code ?? 0);
});
for (const s of ['SIGINT', 'SIGTERM']) {
process.on(s, () => {
worker.kill(s);
child.kill(s);
});
}