Re: [systemd-devel] Alias for SMTP providers [ie. mutually exclusive service alternatives]

2021-06-18 Thread Cristian Rodríguez
On Tue, Jun 15, 2021 at 5:13 AM Kenneth Porter  wrote:
>
> What happens if I list multiple services in a Wants= and After= clause that
> are mutually exclusive (eg. sendmail/postfix/exim? How can I say "This unit
> needs to send mail" without knowing which is enabled?

Unfortunately "need to send mail" is not well defined..

a) does it need to talk to smtp/smpts/submission ports ? then your
smtp daemon needs to socket activate properly
b) Needs to execute the sendmail binary ? your sendmail command must
queue your messages for "later",

Otherwise your service must start after any of this services but not
want any of them, bad news is it will race anyway  and your app still
shouldn't care about what daemon or not is handling the email so goto
a)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Alias for SMTP providers [ie. mutually exclusive service alternatives]

2021-06-16 Thread Kenneth Porter
--On Wednesday, June 16, 2021 11:46 AM +0300 Mantas Mikulėnas 
 wrote:



What does "needs to send mail" even mean? That /usr/sbin/sendmail can
be called to queue a message? That you can talk to localhost:25?

A well behaving MTA actually make /usr/sbin/sendmail work without the
main mail daemon to be up. The mail is then only enqueued, but not
dispatched, but that'll be done once the service is fully up.



Hmm, I was going to post the same at first, but it doesn't really work in
reverse -- if you want to send mail on shutdown and if the goal of
After=postfix is "run my ExecStop before postfix gets stopped", then
ability to queue doesn't help all that much.


This isn't that intractable. The objective is to allow the message to 
escape the box to the next hop before shutdown. (On startup there's no 
issue.) So I can issue a queue flush in the ExitStop and then poll the 
queue for empty until a timeout (say, 5 seconds) is reached to allow the 
queue to drain. Admittedly this won't work on a system that's getting 
flooded with mail from other sources. On a lightly-loaded system, just 
sleeping for 2-5 seconds is enough to let the message escape.


My current workflow for a reboot is to mail myself the result of uptime and 
then start a ping from another box to monitor when it comes back up. So I'm 
trying to script away from that to just looking at that server's mail 
folder.


My bigger concern is how to use one Unit file to handle different MTAs.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Alias for SMTP providers [ie. mutually exclusive service alternatives]

2021-06-16 Thread Mantas Mikulėnas
On Wed, Jun 16, 2021 at 10:43 AM Lennart Poettering 
wrote:

> On Di, 15.06.21 02:03, Kenneth Porter (sh...@sewingwitch.com) wrote:
>
> > What happens if I list multiple services in a Wants= and After= clause
> that
> > are mutually exclusive (eg. sendmail/postfix/exim? How can I say "This
> unit
> > needs to send mail" without knowing which is enabled?
>
> What does "needs to send mail" even mean? That /usr/sbin/sendmail can
> be called to queue a message? That you can talk to localhost:25?
>
> A well behaving MTA actually make /usr/sbin/sendmail work without the
> main mail daemon to be up. The mail is then only enqueued, but not
> dispatched, but that'll be done once the service is fully up.
>

Hmm, I was going to post the same at first, but it doesn't really work in
reverse -- if you want to send mail on shutdown and if the goal of
After=postfix is "run my ExecStop before postfix gets stopped", then
ability to queue doesn't help all that much.

-- 
Mantas Mikulėnas
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Alias for SMTP providers [ie. mutually exclusive service alternatives]

2021-06-16 Thread Lennart Poettering
On Di, 15.06.21 02:03, Kenneth Porter (sh...@sewingwitch.com) wrote:

> What happens if I list multiple services in a Wants= and After= clause that
> are mutually exclusive (eg. sendmail/postfix/exim? How can I say "This unit
> needs to send mail" without knowing which is enabled?

What does "needs to send mail" even mean? That /usr/sbin/sendmail can
be called to queue a message? That you can talk to localhost:25?

A well behaving MTA actually make /usr/sbin/sendmail work without the
main mail daemon to be up. The mail is then only enqueued, but not
dispatched, but that'll be done once the service is fully up.

A well behaving MTA would also support socket activation, so that the
port 25 is already bound while the daemon tarts up. This means that no
ordering for regular services is necessary.

Anyway, we do not provide any generic target for this, but your distro
might add that.

Lennart

--
Lennart Poettering, Berlin
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Alias for SMTP providers [ie. mutually exclusive service alternatives]

2021-06-15 Thread Kenneth Porter
What happens if I list multiple services in a Wants= and After= clause that 
are mutually exclusive (eg. sendmail/postfix/exim? How can I say "This unit 
needs to send mail" without knowing which is enabled?


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel