Which signal handling strategy ensures zero-downtime restarts in a Plack-based Perl application?
19K reputation · 21 May 2020, 12:28 UTC
Graceful Process Migration in Perl
When migrating or updating a small Perl application deployed via a PSGI interface, the goal is to replace the running process without dropping active connections. While pre-forking servers like Starman support signal-based management, the interaction between the master process and worker children during a reload can introduce state inconsistencies.
The primary constraint involves managing global variables and module-level state. If a process is signaled to reload, existing stateful modules may persist in memory, potentially leading to configuration drift or memory leaks if the internal state is not explicitly cleared before the new worker takes over.
Does the standard SIGHUP behavior in a pre-forking Perl environment guarantee that all active sockets are drained before the parent process terminates the old worker? Which specific mechanism is recommended to ensure that global state is fully reset during a zero-downtime transition?