listmonk icon indicating copy to clipboard operation
listmonk copied to clipboard

Systemd service fails to start

Open runningnoodle opened this issue 1 year ago • 4 comments

Version: v2.4.0 OS: Ubuntu 22.04

Description of the bug

The systemd service created with the [email protected] file fails to start.

Steps to reproduce

  1. Make sure that the listmonk binary is at /usr/bin/listmonk and that the config file is at /etc/listmonk/mailer.toml
  2. Download the [email protected] file in /etc/systemd/system cd /etc/systemd/system wget https://raw.githubusercontent.com/knadh/listmonk/c10c03178ba6da1e2f8cb61f624b4e691c85af27/listmonk%40.service
  3. Load the [email protected] file systemctl daemon-reload
  4. Try to start the listmonk service systemctl start listmonk@mailer

Expected result

Listmonk should start. It should start sending emails and the dashboard should become available.

This is the result you get when using Listmonk v2.3.0.

Actual result

The dashboard and listmonk itself don't start. You get the following error: Job for [email protected] failed because a fatal signal was delivered causing the control process to dump core. See "systemctl status [email protected]" and "journalctl -xeu [email protected]" for details.

Proposed fix

#1309

runningnoodle avatar May 07 '23 15:05 runningnoodle

Can you post the complete logs under journalctl -xeu [email protected]?

mr-karan avatar May 08 '23 10:05 mr-karan

Could this be related to this? https://github.com/NixOS/nixpkgs/issues/197443

image

rhnvrm avatar May 08 '23 11:05 rhnvrm

As requested, here is the output from journalctl -xeu [email protected] after trying to start listmonk with @resources disallowed: journal.txt

In order to investigate this further, I have added SystemCallLog=@resources to both the systemd service files. This allowed me to get logs of any system calls attempted by listmonk that are part of the @resources group.

When running listmonk with @resources allowed, I noticed the following lines in the resulting log file: May 9 16:41:54 lm kernel: [ 255.860803] audit: type=1326 audit(1683664914.251:36): auid=4294967295 uid=63407 gid=63407 ses=4294967295 subj=unconfined pid=1097 comm="listmonk" exe="/usr/bin/listmonk" sig=0 arch=c000003e syscall=160 compat=0 ip=0x40394e code=0x7ffc0000 May 9 16:41:54 lm kernel: [ 256.036426] audit: type=1326 audit(1683664914.427:37): auid=4294967295 uid=63407 gid=63407 ses=4294967295 subj=unconfined pid=1103 comm="listmonk" exe="/usr/bin/listmonk" sig=0 arch=c000003e syscall=160 compat=0 ip=0x40394e code=0x7ffc0000

With @resources disallowed, I see similar lines, but more of them.

It looks like the culprit is system call 160 (setrlimit). This is the same system call as in the other case found by @rhnvrm. I believe that upgrading to Go 1.19 was the reason that this system call gets used by v2.4.0.

runningnoodle avatar May 09 '23 21:05 runningnoodle

Version: v2.4.0 OS: Ubuntu 22.04

Description of the bug

The systemd service created with the [email protected] file fails to start.

Indeed, to run Listmonk as systemd service was not so easy, it failed many times until I removed a few lines from .service (see below). OK, my Ubuntu is not the latest one, but still, it should be supported. Here the software versions:

Ubuntu 18.04.2 LTS
systemd 237
listmonk v2.4.0 (c668523 2023-03-20T13:50:31Z) (just the binary, without Docker)

I managed to run Listmonk by removing a few things from the .service file My service file attached (renamed to listmonk.service.txt - otherwise github does not allow it): listmonk.service.txt ...it might be useful when you decide to support older Ubuntu versions I removed these lines (and may be something else) and added a few minor things:

SystemCallFilter=
DeviceAllow=

By the way, when troubleshooting systemd issues - always specify the systemd version! Many systems have old systemd - it just does not know about the latest features/parameters in .service file!

stargazer33 avatar May 10 '23 20:05 stargazer33

This is still broken, why was it closed?

gdevenyi avatar Feb 29 '24 04:02 gdevenyi

Providing the proper reference for the fix, https://github.com/knadh/listmonk/pull/1309

gdevenyi avatar Feb 29 '24 04:02 gdevenyi

Hi @gdevenyi. There's an open PR (unresolved) pertaining to this: https://github.com/knadh/listmonk/pull/1614

I've been unable to delve into the nuances of this issue, unfortunately. Would be happy to merge a PR that addresses the unresolved issues.

knadh avatar Feb 29 '24 05:02 knadh