Skip to main content

Module foreground

Module foreground 

Source
Expand description

Supervised serve --foreground entry point (issue #787).

Why: launchd supervisors need loud failure on port collision, not silent port-walking to 7071+. Extracted to stay under the 500-line ratchet cap. What: exports bind_foreground_port (Fix C — abort on EADDRINUSE) and run_http_foreground (Fix A lock + Fix B http_addr + Fix C combined). Test: foreground::tests::bind_foreground_port_refuses_collision; daemon_lock module tests cover the lock-file logic. Supervised serve --foreground entry point (issue #787).

Why: extracted from lib.rs to keep that file under the 500-line-cap ratchet budget. All three issue-#787 fixes (lock file ownership, http_addr guarantee, bind-abort-on-collision) live here so they are easy to find and test together. What: exports bind_foreground_port (Fix C) and run_http_foreground (Fix A + Fix B + Fix C combined entry point) for use by main.rs. Test: bind_foreground_port_refuses_collision (unit, real TCP bind); daemon_lock module tests cover the lock-file logic.

Functions§

bind_foreground_port
Bind a TcpListener to 127.0.0.1:DEFAULT_HTTP_PORT for the launchd/supervisor serve --foreground path — abort on collision.
run_http_foreground
The canonical serve --foreground entry point used by launchd and systemd supervisors (issue #787).