1

Periodically, I see the following in syslog:

systemd[1]: spamassassin.service: Main process exited, code=exited, status=255/n/a
systemd[1]: spamassassin.service: Unit entered failed state.
systemd[1]: spamassassin.service: Failed with result 'exit-code'.

but the service does not automatically restart. It does start successfully with:

sudo service spamassassin restart

Can I configure spamassassin to restart automatically after it fails?

flymike
  • 287
  • 3
  • 13
  • 1
    There is no component to 'restart' SpamAssassin by-default. You would have to configure some type of monitoring system that'd run to monitor software programs on the system and start them again if they are down. However, this is actually not going to solve the underlying problem of SpamAssassin occasionally closing or shutting off or crashing. The actual question you *should* be asking **first** is: "Why did SpamAssassin fail to start or fail to shut down gracefully?". Have you examined why it's dying first? – Thomas Ward Jun 04 '18 at 23:02
  • You're right. But I was multi-tasking - addressing both the failure cause and the possibility of restart after failure at the same time. – flymike Jun 05 '18 at 04:08

1 Answers1

1

The manpage for systemd.service has the answer. For my particular case, the simplest solution was to add:

Restart=always
RestartSec=3

to the [Service] section of /lib/systemd/system/spamassassin.service

But there are more sophisticated controls available to limit restarts, should a failure loop occur.

flymike
  • 287
  • 3
  • 13