Built with Chinaski

Hypnotoad: Zero-Downtime Reloads

Hypnotoad’s hallmark is reloading without dropping connections. That is done by signaling the running master process with the PID file the server keeps:

kill -USR2 $(cat hypnotoad.pid)

What happens under the hood: a new worker set starts, traffic drain continues on the old workers until they finish in-flight requests, and new requests are served by the fresh set — no listener downtime. The shipped config sets a graceful timeout (graceful_timeout => 20) bounding how long the draining may take.

Reload applies to code changes: after editing Perl files (e.g. applying an update by hand or a plugin fix), issue the USR2 reload and request workers pick up the new code.

  • Graceful stop (hypnotoad -s cms.pl) closes the listener and waits for workers to drain, but is not the zero-downtime path.
  • Systemd deployments use the unit’s own restart — hot reload semantics live under the daemon’s own control, so use systemctl restart chinaski@<N> there (the unit sets a generous stop timeout of 330 s specifically to let in-flight requests drain safely, though builds are much longer than that; the build process itself completes outside the window).

The kill signal dance changed nothing about Chinaski’s architecture; the USR2 pinning is standard Mojolicious hypnotoad behavior, documented for when hypnotoad is your front server.