On Fri, Jan 06, 2023 at 06:42:18PM +0100, Peter Wienemann wrote:

> Most changes in main.cf require a reload to become effective

No. In most cases they merely require the passage of time, and typical
changes are not that time-sensitive.

> I am trying to put main.cf under configuration 
> management and have to trigger an action each time main.cf changes such 
> that the changes become effective.

If you make changes to main.cf that are time-sensitive, push a separate
file whose update will cause a reload.  If your changes require a
restart, push a separate file whose update triggers a restart.  Most of
the time leave both sentinel files alone.

> At the moment I always perform a restart after a change of main.cf
> (just to be on the safe side).

This is not necessary in most cases, and should be avoided if possible.

> But on a busy mail server this is not ideal. I am looking for a way to
> do better. One idea that came to my mind is:

Reloads are also not ideal.

> 1. Initially try a reload and check whether the effective configuration 
> is different from the target configuration as specified in main.cf.
> 
> 2. If both match, we are done. If there is a discrepancy, launch a restart.

You're over-engineering the problem.  Let the operator who authors the
change decide whether a restart or reload is required, or whether just
normal Postfix process recycling is sufficient for your needs.

On a busy server, you can reduce max_idle and or max_use to recycle
processes more often:

    max_idle = 3s
    max_use = 20

Most smtpd(8) processes and delivery agents would last not much longer
than a minute before they exit and are replaced.  The additional cost
of process creation will be modest.

-- 
    Viktor.

Reply via email to