module

ServerX::Cluster

Master process: forks N workers, each binding with SO_REUSEPORT (the kernel load-balances), supervises and restarts dead children. On SIGTERM/SIGINT it forwards the signal, waits for the workers to drain their in-flight requests (up to shutdown_timeout), then kills stragglers and exits 0 — the nginx master model.

Liveness is tracked with one blocking Process#wait monitor fiber per child. (The Crystal runtime reaps all children itself via SIGCHLD + waitpid(-1, WNOHANG), so polling waitpid/#exists? from the master cannot see a dead child — zombies never surface.)

Class methods

run(host : String, port : Int32, workers : Int32, worker_block : Proc(Nil), shutdown_timeout : Time::Span = 15.seconds) : Nil
Source
stats_printer(stats : Stats, interval : Int32) : Nil

Prints cumulative totals plus per-window deltas. gc_win_kb is the GC churn metric: how much garbage the run allocated in the last window while serving reqs_win requests.

Source