Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #200474 > unrolled thread

exim4 only queues mails sent by systemd service

Started bykjonca@poczta.onet.pl (Kamil Jońca)
First post2018-09-23 13:10 +0200
Last post2018-10-03 10:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.debian.user


Contents

  exim4 only queues mails sent by systemd service kjonca@poczta.onet.pl (Kamil Jońca) - 2018-09-23 13:10 +0200
    Re: exim4 only queues mails sent by systemd service kjonca@poczta.onet.pl (Kamil Jońca) - 2018-10-03 09:10 +0200
      Re: exim4 only queues mails sent by systemd service <tomas@tuxteam.de> - 2018-10-03 10:00 +0200

#200474 — exim4 only queues mails sent by systemd service

Fromkjonca@poczta.onet.pl (Kamil Jońca)
Date2018-09-23 13:10 +0200
Subjectexim4 only queues mails sent by systemd service
Message-ID<wBar0-9T-5@gated-at.bofh.it>
It is something strange with sending mails from systemd system service:
assume we have service file /etc/systemd/system/mailtest.service:

--8<---------------cut here---------------start------------->8---
[Unit]
Description="Test maili"
[Service]
#User=kjonca
NoNewPrivileges=false
Type=oneshot
ExecStart=-zsh -c 'echo xxx|mail news'
ExecStart=-zsh -c 'echo xxx|mutt -F /dev/null -s subject -e \'set copy=no\' kjonca'
--8<---------------cut here---------------end--------------->8---

When i call
sudo systemctl start mailtest.service
Two messages are put in exim queue, but not deliveried immediately.
Why? What am I missing?
Morevoer this service run as "--user" service works as expected - mails
are delivered at once.
KJ

-- 
http://wolnelektury.pl/wesprzyj/teraz/
Better hope the life-inspector doesn't come around while you have your
life in such a mess.

[toc] | [next] | [standalone]


#200841

Fromkjonca@poczta.onet.pl (Kamil Jońca)
Date2018-10-03 09:10 +0200
Message-ID<wEJsd-61r-1@gated-at.bofh.it>
In reply to#200474
kjonca@poczta.onet.pl (Kamil Jońca) writes:

> It is something strange with sending mails from systemd system service:
> assume we have service file /etc/systemd/system/mailtest.service:
>

After discussion on systemd list, it turned out that we have race
condition here.

1. exim forks and creates background process to deliver mail
2. systemd, after main process exits, kill all remaining proceses, so
...
3. background process are killed during delivery, and message remains in
queue.

I think this is important for services sending mails (for example
logrotate with mail option)

There are two solutions/workarounds:
1. migrate to postfix :)
2. set KillMode=none in service file.
KJ

-- 
http://stopstopnop.pl/stop_stopnop.pl_o_nas.html
Platonic Shadow:
	A nonsexual friendship with a member of the opposite sex.
		-- Douglas Coupland, "Generation X: Tales for an Accelerated
		   Culture"

[toc] | [prev] | [next] | [standalone]


#200842

From<tomas@tuxteam.de>
Date2018-10-03 10:00 +0200
Message-ID<wEKeB-6gQ-3@gated-at.bofh.it>
In reply to#200841

[Multipart message — attachments visible in raw view] — view raw

On Wed, Oct 03, 2018 at 08:48:51AM +0200, Kamil Jońca wrote:
> kjonca@poczta.onet.pl (Kamil Jońca) writes:
> 
> > It is something strange with sending mails from systemd system service:
> > assume we have service file /etc/systemd/system/mailtest.service:
> >
> 
> After discussion on systemd list, it turned out that we have race
> condition here.
> 
> 1. exim forks and creates background process to deliver mail
> 2. systemd, after main process exits, kill all remaining proceses, so
> ...
> 3. background process are killed during delivery, and message remains in
> queue.
> 
> I think this is important for services sending mails (for example
> logrotate with mail option)
> 
> There are two solutions/workarounds:
> 1. migrate to postfix :)
> 2. set KillMode=none in service file.

3. use another init.

Cheers
-- t

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web