Skip to content

Add Server::Starter FD passing support#39

Closed
jjn1056 wants to merge 3 commits intomainfrom
feat/server-starter
Closed

Add Server::Starter FD passing support#39
jjn1056 wants to merge 3 commits intomainfrom
feat/server-starter

Conversation

@jjn1056
Copy link
Copy Markdown
Owner

@jjn1056 jjn1056 commented Feb 11, 2026

Summary

  • Automatic detection of $ENV{SERVER_STARTER_PORT} for zero-downtime binary upgrades via Server::Starter
  • Parses host:port, port-only, IPv6, and Unix socket address formats
  • Works with both single-worker and multi-worker modes
  • Socket FD preserved on shutdown (owned by Server::Starter, not PAGI)
  • Mutually exclusive with explicit host/port options
  • Full POD documentation with usage examples

Stacked on #38 (access log format) — merge that first, then rebase this onto main.

Test plan

  • prove -l t/45-server-starter.t — 10 subtests: address parser (host:port, port-only, unix path, IPv6, multiple entries), single-worker integration, mutual exclusivity with host/port, shutdown FD preservation, multi-worker integration
  • prove -l t/ — full test suite (no regressions)
  • Manual: start_server --port 5000 -- perl -Ilib bin/pagi-server ./examples/01-hello-http/app.pl

🤖 Generated with Claude Code

jjn1056 and others added 3 commits February 10, 2026 21:08
Detect $ENV{SERVER_STARTER_PORT} automatically at startup. Parse the
env var to extract address and file descriptor (supports host:port=fd,
port=fd, /path=fd, and [ipv6]:port=fd formats).

When Server::Starter is detected:
- Reuse the inherited socket FD instead of binding a new socket
- Reject explicit host/port options (mutual exclusivity)
- For SSL, use per-connection SSL_upgrade pattern
- Preserve socket FD on shutdown (Server::Starter owns it)
- Show "server-starter" in startup log

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In multi-worker mode with SERVER_STARTER_PORT, reuse the inherited FD
as the shared listen socket instead of creating a new one. Skip
reuseport probe. Workers receive the socket via fork inheritance and
don't re-detect the env var.

Shutdown guard prevents closing the Server::Starter socket. Startup
log shows "server-starter" mode string. Also pass access_log_format
to worker server instances.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add SERVER::STARTER INTEGRATION section to Server.pm POD covering:
- How the automatic detection works
- Usage with start_server command
- Constraints (mutual exclusivity with host/port, socket ownership)
- Relevant environment variables

Add SERVER::STARTER section to bin/pagi-server with usage examples.
Add SERVER_STARTER_PORT and SERVER_STARTER_GENERATION to ENVIRONMENT.
Add note to host/port constructor docs about Server::Starter override.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Base automatically changed from feat/access-log-format to main February 11, 2026 16:51
@jjn1056 jjn1056 closed this Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant