Skip to content

Hot reload — reload application code without dropping connections #93

Description

@EdmondDantes

Motivation

The server is long-lived: handler/bootloader code stays resident in each worker, so today any change to the PHP app requires a full process restart — which drops every in-flight and idle connection. We want to reload the application code in place, keeping listeners and live connections alive.

Scope

  • Trigger: file-watcher (inotify) for dev; a signal (SIGHUP) and/or an admin API for prod.
  • Reload: per-worker rolling reload — a worker stops accepting, drains in-flight requests via the existing shutdown-drain machinery (Server shutdown disposes server_scope while per-request coroutines are still in-flight #74), re-runs the bootloader (HttpServerConfig::setBootloader) to re-register handlers, resets opcache, then resumes. Other workers keep serving throughout → zero downtime.
  • Preserve across reload: the listener sockets (don't rebind), and long-lived streams (WebSocket / SSE) — either drained with a 1001 Going Away / stream close, or handed to the new code where safe.

Open questions

  • opcache invalidation strategy (full reset vs per-file).
  • What worker state is allowed to survive a reload (bootloader-owned singletons, pools).
  • Interaction with setWorkers() / the reactor pool.

Brief for now — filing so it isn't lost.

Activity

  1. added this to the Next2 milestone on Jul 1, 2026
  2. self-assigned this
    on Jul 1, 2026
  3. 20 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions