Introduce spawner app with sandboxing support and client protocol implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OverlordandClaude Bot committed 2026-10-12 23:49:05 +02:00
1 parent 571f43457d
commit 7b1df2607e
26 files changed
+2438 -5

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { chmodSync, rmSync } from 'node:fs';
import { loadConfig } from './config.ts';
import { SandboxManager } from './sandbox.ts';
import { createSpawnerServer } from './server.ts';
const log = (message: string) => console.log(`[spawner] ${message}`);
const config = loadConfig(process.env);
const manager = new SandboxManager(config);
await manager.assertRuntime();
const reaped = await manager.reapOrphans();
if (reaped > 0) log(`removed ${reaped} orphaned sandbox(es)`);
// The socket must never be reachable by anyone outside the shared group,
// not even for the moment between creating it and changing its mode.
process.umask(0o117);
rmSync(config.listenSocket, { force: true });
const server = createSpawnerServer(manager, log);
server.listen(config.listenSocket, () =>
{
chmodSync(config.listenSocket, 0o660);
log(`listening on ${config.listenSocket}`);
});
for (const signal of ['SIGTERM', 'SIGINT'] as const)
{
process.once(signal, () => {
server.close();
process.exit(0);
});
}