Re: The saga of wrestling with systemd (was) Re: logrotate options?

"Joe Acquisto-j4" <[email protected]> Sun, 23 Jan 2022 15:21:06 -0500
Newsgroups gmane.mail.fetchmail.user
Message-ID <[email protected]>
. . .
> It's great that you got it running! Congratulations!
> (yes, I know that fighting with systemd service and unit definition
>  files for the first time... or sometimes even for the fifteenth time...
>  may be, um, exhausting. There is some logic to them, but it takes
>  a while to get used to it)
> 
> If I may make a couple of comments to what you showed below...
> 
>> [Unit]
>> Description=remote-mail retrieval utility runin daaemon mode
> 
> A couple of typos there ("runin", "daaemon"), but I guess they won't
> affect the operation of the service :)

Yeah, I left them as an indication of the "quality of my work"
 
>> After=network.target
>> Wants=network.target
>> 
>> [Service]
>> Type=simple
>> EnvironmentFile=/root/.fetchmailrc
> 
> Hm. This one looks a bit weird to me. I don't think that your
> .fetchmailrc file is indeed in the "variable=value" format that systemd
> would expect for a file to read environment variables from. Also,
> I don't think that your .fetchmailrc file even contains environment
> variable settings...
> 
> Does it work if you remove this line? If so, then I think you may want
> to remove it.

Yes, it works either way.  I did see that it was probably for an actual environment variable
file, but I put it in when it did not seem to be reading some of my set commands.   After
I confirmed it was not what I wanted, I left it uncommented.  It is now uncommented.

> 
>> #User=fetchmail
>> #ExecStart=/usr/lib/fetchmail-systemd-exec
>> ExecStart=/usr/local/bin/fetchmail -v
>> #-Nd120
> 
> This will only work if your .fetchmailrc file already contains
> a "set daemon ..." line and also a "nodetach" line. Otherwise, systemd
> will be kind of surprised when fetchmail creates a separate daemon
> process in the background and the fetchmail process that systemd started
> decides to exit since it has done its part of the work (started
> the daemon process in the background). If your .fetchmailrc file has
> the "set daemon" and "nodetach" lines, then yeah, this will work.

I went with removing those items from the command line as I was having issues
with a single line (non verbose) of the log, one per "poll" going to /var/log/fetchmail
and the verbose part (fetching) going to /var/log/messages.  

My .fetchmailrc does have set daemon, but not "nodetach" which does not seem to 
be a set command.

In any case, it works fine, but on "stop" it quits but gives the "failed" message
below.  It does stop as shown and does not seem to affect restart.  So far.

Jan 23 15:01:03 auxilary fetchmail[11981]: fetchmail: background fetchmail at 11958 killed.
Jan 23 15:01:03 auxilary systemd[1]: fetchmail.service: Unit entered failed state.
Jan 23 15:01:03 auxilary systemd[1]: fetchmail.service: Failed with result 'exit-code'.

This really does not bother me, but might look into it at leisure.

 . . .
> G'luck,
> Peter
> 
> -- 
> 

Again, thanks to all, your assistance was most helpful. 

joe a.