Problem
tri queen start --daemon is a stub — it prints messages but doesn't actually daemonize. This causes a restart loop when supervisor scripts try to run it.
Current State
// src/queen/queen_trinity.zig:304-316
fn runQueenStart(allocator: Allocator, args: []const []const u8) !void {
if (daemon_mode) {
std.debug.print("👑 Queen starting in daemon mode...\n", .{});
std.debug.print(" Daemon mode: Running (background)\n", .{});
}
// Function exits — no actual daemonize!
}
Result: 20,000+ lines in launcher.err showing restart loop.
Requirements
- fork() + detach — proper Unix daemon pattern
- PID file — write to
.trinity/queen/queen.pid
- Signal handling — SIGTERM for graceful shutdown
- Stdio redirection — stdout/stderr → launcher.log
- Idempotency — check if already running, don't duplicate
Implementation Plan
- Add
std.posix.fork() with double-fork pattern
- Write PID file on successful daemonize
- Setup signal handlers (SIGTERM, SIGINT)
- Redirect stdio to log file
- Add
tri queen stop command (read PID, send SIGTERM)
Success Criteria
References
- Queen state:
.trinity/queen_state.json
- Doctor binary:
./zig-out/bin/queens doctor
φ² + 1/φ² = 3 = TRINITY
Problem
tri queen start --daemonis a stub — it prints messages but doesn't actually daemonize. This causes a restart loop when supervisor scripts try to run it.Current State
Result: 20,000+ lines in
launcher.errshowing restart loop.Requirements
.trinity/queen/queen.pidImplementation Plan
std.posix.fork()with double-fork patterntri queen stopcommand (read PID, send SIGTERM)Success Criteria
tri queen start --daemonreturns immediatelyps aux | grep queenshows running daemontri queen stopgracefully terminatesReferences
.trinity/queen_state.json./zig-out/bin/queens doctorφ² + 1/φ² = 3 = TRINITY