A.Schulze via Postfix-users:
> Hello,
> 
> I like to ask if postfix/master process can simply behave like a supervisor 
> to keep a non postfix process simply up and running.
> It should start a process and if the process exit for any reason, it should 
> be restarted after a short delay (optional: some logging)
> 
> My use-case is a postfix instance running in a container. postfix is started 
> with "start-fg" and master has PID 1
> 
> STDIN is /dev/null, STDOUT+STDERR may be /dev/null, handled by postlog or the 
> process write to container's /dev/stdout
> 
> https://www.postfix.org/master.5.html clearly say, such mode is not possible 
> today. So it would be like a feature request.
> It mention spawn for that job. But spawn has limitations not fitting for a 
> process like postfix-tlspol [1]
> 
> Why not use a separate container? My postfix-container have dedicated, fixed 
> ip addresses. Using separate container would require additional ip addresses
> or data will flow different then connections initiated by the 
> postfix-container itself.
> (sounds scary, local limitations ...)
> 
> Does that make sense? Do I oversee an other possibility?

Short anwer: to fit Postfix, your application would need to provide
some kind of service, or at least be willing to receive (and discard)
Postfix wakeup messages on a service socket that is created by the
Postfix master daemon.

Longer answer:

The Postfix master daemon monitors a service socket and runs a child
process when the socket shows activity (there is some support for
using a FIFO instead of socket, and some logic to prevent crash-loop
conditions, but that is not relevant for the question at hand).

The master's child process then accepts a connection on the socket,
reads from the accepted socket and that writes to the accepted
socket, closes the accepted socket after servicing a client, and
waits for the next request for service, and terminates after a 100s
timer goes off or after servicing 100 connections.

The master daemon can simulate a persistent server. This involves
a wakeup timer in master.cf, sending a wakeup message to a service
socket. If the master's child process disables its limit for the
number of service requests, then the master's child process keeps
running until Postfix is stopped or reloaded.

Only Postfix programs can be configured as a Postfix service.
Non-Postfix programs must be run outside the Postfix trust perimeter,
as a child of the local(8), pipe(8), or spawn(8) daemon.

Maybe a spawn-like daemon can be tweaked to pass the service socket
to the non-Postfix process and just wait until the non-Postfix
process terminates, without enforcing any process time limit. This
would need some safety to prevent crash-loop conditions. And the
non-Postfix process would have to receive and discard wakeup messages.

Finally, all Postfix daemons have a watchdog timer that kills a
process that appears to be stuck. The spawn-like daemon can be made
to wake up periodically and refresh its watchdog. But the non-Postfix
process would have to implement its own watchdog mechanism.

        Wietse
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to