test / test (push) Canceled after 0s
C-P42. postfix-script's start-fg runs master as its child and master calls setsid() (Postfix 3.7.11, conf/postfix-script; src/master/master.c); supervisord signals the pid alone (supervisor 4.2.5, process.py, Subprocess.kill()). A stop of program postfix left master running - a restart then found "already running" - and a container stop cut Postfix off with SIGKILL. The wrapper now stays the parent of "postfix start-fg" and on TERM/INT runs "postfix stop", asking again while start-fg is still in its checks (master -t). stopwaitsecs=15. C-V6. The wrapper's give-up on the milter sockets came after the default startsecs, so it was EXITED and restarted for ever. startsecs is now MILTER_WAIT_TIMEOUT + 10, exported by the entrypoint as POSTFIX_STARTSECS and expanded by supervisord (options.py, processes_from_section(); a non-number MILTER_WAIT_TIMEOUT stops the start): a give-up is "Exited too quickly", BACKOFF, FATAL after startretries, crashexit. For those seconds after each start the program is STARTING (the healthcheck's 90 s start period covers it; the sender check counts no downtime then). C-V5. logrotate had startsecs=0, so a refused config restarted it every second for ever. startsecs=1: FATAL after startretries; crashexit reads the event's processname and leaves logrotate's FATAL on Server > Health. B-U2. "supervisorctl start" returns when a startsecs=0 program is RUNNING, not when it ends, and mapped "already started" to success. The panel now speaks supervisord's XML-RPC itself (internal/supervisor, RunOnce): startProcess without waiting, getProcessInfo until it leaves STARTING/RUNNING, exitstatus 0 or an error; a run in progress is waited out and one of its own follows. A failed reload while program postfix is not RUNNING is logged, not an error: the next master reads the files. C-V10: postfix-reload rests EXITED after a run; the e2e process check takes STOPPED or EXITED. C-P34: the dead "postfix set-permissions" branch goes - postfix check's create-missing builds the queue tree. Stand (2026-10-14, make e2e, exit 0; MILTER_WAIT_TIMEOUT=10 on the stand): new supervision_stops_postfix_and_gives_up - supervisorctl restart postfix writes postfix-script's "stopping the Postfix mail system" and leaves one master; with the panel's sockets removed, start answers "postfix: ERROR (spawn error)" (finish() sets spawnerr "Exited too quickly", onwait() reads it first) and Postfix comes up once the panel is back; a group-writable logrotate config ends FATAL with the container up; the panel's Reload configuration answers only after mail.log has "refreshing the Postfix mail system", postfix-reload EXITED. session_survives_restart sees the stop line for the container's restart. Measured: master's own "terminating on signal 15" never reaches mail.log (master TERMs its group, postlogd included, before it logs). go vet and go test ./... pass on the server (24 packages; new unit tests of RunOnce against a fake supervisord). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
166 lines
6.6 KiB
Plaintext
166 lines
6.6 KiB
Plaintext
; SelfPost process supervision.
|
|
;
|
|
; Start ORDER is enforced by priority=: OpenDKIM, then the panel (which opens
|
|
; the sender check's and the journal-milter's sockets), then the Postfix
|
|
; wrapper — which additionally blocks until the milter sockets are ready
|
|
; before starting Postfix. (supervisor 4.2.5, docs/configuration.rst,
|
|
; [program:x] "priority": "the start and shutdown ordering"; supervisor/
|
|
; supervisord.py, runforever(), transitions every group in that order in one
|
|
; pass, with no wait for a program to be ready.)
|
|
;
|
|
; If a managed process of the mail path exhausts its restart retries (FATAL),
|
|
; the crashexit event listener brings the whole container down so Docker's
|
|
; restart policy starts it again (the same container: docs.docker.com, "Start
|
|
; containers automatically", restart policies), rather than lingering with a
|
|
; dead component. A program reaches FATAL only through BACKOFF, by exits that
|
|
; come before its startsecs (supervisor 4.2.5, supervisor/process.py,
|
|
; Subprocess.finish() and transition()): an exit after it is EXITED and simply
|
|
; restarted, for ever. logrotate's FATAL is left on Server > Health
|
|
; (build/crashexit.py).
|
|
|
|
[supervisord]
|
|
nodaemon=true
|
|
user=root
|
|
logfile=/dev/null
|
|
logfile_maxbytes=0
|
|
pidfile=/run/supervisord.pid
|
|
loglevel=info
|
|
|
|
; The control socket is reachable by the shared `selfpost` group so the panel
|
|
; (running as the unprivileged `panel` user) can ask supervisord to send
|
|
; OpenDKIM a reload signal after it rewrites the DKIM tables. It is still
|
|
; unreachable by world; only root and the two SelfPost services are in the
|
|
; group. No HTTP auth is configured because access is gated by socket
|
|
; permissions, not the network. (supervisor 4.2.5, docs/configuration.rst,
|
|
; [unix_http_server]: chmod and chown set the socket's mode and owner; without
|
|
; username and password no authentication is asked.)
|
|
[unix_http_server]
|
|
file=/run/supervisor.sock
|
|
chown=root:selfpost
|
|
chmod=0770
|
|
|
|
[rpcinterface:supervisor]
|
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
|
|
|
[supervisorctl]
|
|
serverurl=unix:///run/supervisor.sock
|
|
|
|
[program:opendkim]
|
|
command=/usr/sbin/opendkim -f -x /etc/opendkim.conf
|
|
priority=100
|
|
autostart=true
|
|
autorestart=true
|
|
startretries=3
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; user=panel also gives the panel its supplementary groups, selfpost and
|
|
; postdrop (build/Dockerfile): supervisor 4.2.5, supervisor/options.py,
|
|
; drop_privileges(), os.setgroups() from the user's memberships in
|
|
; grp.getgrall().
|
|
[program:panel]
|
|
command=/usr/local/bin/panel
|
|
user=panel
|
|
priority=200
|
|
autostart=true
|
|
autorestart=true
|
|
startretries=3
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; startsecs is MILTER_WAIT_TIMEOUT plus ten seconds (build/entrypoint.sh): the
|
|
; wrapper's exit when the milter sockets never come counts as too quick, and
|
|
; so does a Postfix that will not start. The price: for that long after each
|
|
; start the program is STARTING, not RUNNING (supervisor 4.2.5,
|
|
; supervisor/options.py, processes_from_section(): startsecs is expanded like
|
|
; any value, %(ENV_x)s from supervisord's environment; assumptions C-V6).
|
|
; stopwaitsecs covers "postfix stop", which waits five seconds for master
|
|
; before it kills (build/postfix-wrapper.sh).
|
|
[program:postfix]
|
|
command=/usr/local/bin/postfix-wrapper.sh
|
|
priority=300
|
|
autostart=true
|
|
autorestart=true
|
|
startsecs=%(ENV_POSTFIX_STARTSECS)s
|
|
startretries=3
|
|
stopwaitsecs=15
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; One-shot reload helper. The panel runs unprivileged and cannot run `postfix
|
|
; reload` itself, and it cannot signal the Postfix master directly: `postfix
|
|
; start-fg` forks a separate master process, so a signal to the supervised
|
|
; foreground process never reaches it (unlike OpenDKIM, which runs in the
|
|
; foreground as the supervised process itself). Instead the panel asks
|
|
; supervisord — over the group-accessible control socket — to run this program,
|
|
; which executes the canonical `postfix reload` as root. autostart is off (it
|
|
; only runs on demand) and a fast, clean exit is expected, so it never trips the
|
|
; crashexit listener. (start-fg: see build/postfix-wrapper.sh. supervisor
|
|
; 4.2.5, supervisor/process.py, Subprocess.finish(): with startsecs=0 no exit
|
|
; counts as "too quickly", so even a failed run ends EXITED - never BACKOFF,
|
|
; never FATAL - with its exit status kept, which the panel reads
|
|
; (internal/supervisor, RunOnce). Its resting state is STOPPED until the first
|
|
; run, EXITED after it; assumptions C-V10.)
|
|
[program:postfix-reload]
|
|
command=/usr/sbin/postfix reload
|
|
autostart=false
|
|
autorestart=false
|
|
startsecs=0
|
|
startretries=1
|
|
exitcodes=0
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; TLS-certificate refresh. Once a day it compares the certificate the
|
|
; reverse-proxy renews in the read-only mount with the copy Postfix reads, and
|
|
; when they differ copies it again and runs `postfix reload`.
|
|
; Long-running (it loops), runs as root so it can reload Postfix, and never exits
|
|
; non-zero, so it neither trips the crashexit listener nor needs restarting.
|
|
[program:cert-reload]
|
|
command=/usr/local/bin/postfix-cert-reload.sh
|
|
priority=400
|
|
autostart=true
|
|
autorestart=true
|
|
startsecs=0
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; Periodic logrotate for /data/log/mail.log (daily, 14 files kept). Runs as
|
|
; root so logrotate can read/rotate the log. Exits non-zero at once when the
|
|
; config is group/other-writable (logrotate would ignore it silently): with
|
|
; startsecs=1 that exit is too quick; once startretries are spent the program
|
|
; is FATAL, and Server > Health shows it. With startsecs=0 it was restarted
|
|
; every second for ever, RUNNING and EXITED in turn (supervisor 4.2.5,
|
|
; supervisor/process.py, Subprocess.finish(); assumptions C-V5). crashexit
|
|
; leaves this FATAL alone: logrotate is not on the mail path.
|
|
[program:logrotate]
|
|
command=/usr/local/bin/logrotate-loop.sh
|
|
priority=400
|
|
autostart=true
|
|
autorestart=true
|
|
startsecs=1
|
|
startretries=3
|
|
stdout_logfile=/dev/stdout
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|
|
|
|
; supervisor 4.2.5, supervisor/process.py: a program enters FATAL only from
|
|
; BACKOFF, once startretries are spent; a stop asked of supervisord ends in
|
|
; STOPPED (Subprocess.finish(), self.killing), which this listener never sees.
|
|
[eventlistener:crashexit]
|
|
command=/usr/local/bin/crashexit.py
|
|
events=PROCESS_STATE_FATAL
|
|
stderr_logfile=/dev/stderr
|
|
stderr_logfile_maxbytes=0
|