Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maddy systemd service tries to start before network interfaces are up #616

Closed
cuu508 opened this issue Aug 13, 2023 · 0 comments · Fixed by #617
Closed

Maddy systemd service tries to start before network interfaces are up #616

cuu508 opened this issue Aug 13, 2023 · 0 comments · Fixed by #617
Labels
bug Something isn't working.

Comments

@cuu508
Copy link
Contributor

cuu508 commented Aug 13, 2023

Describe the bug

If maddy is managed by systemd using the systemd service file in this repository, when the server reboots, maddy tries to start up too early, before network interfaces are ready. This leads to repeated failed startups, with the error message in logs:

Aug 13 14:42:33 mail2 maddy[1305]: smtp: listen tcp 111.111.111.111:25: bind: cannot assign requested address
Aug 13 14:42:33 mail2 systemd[1]: maddy.service: Main process exited, code=exited, status=1/FAILURE
Aug 13 14:42:33 mail2 systemd[1]: maddy.service: Failed with result 'exit-code'.
Aug 13 14:42:33 mail2 systemd[1]: Failed to start maddy mail server.
Aug 13 14:42:33 mail2 systemd[1]: maddy.service: Scheduled restart job, restart counter is at 4.

The systemd service has a After=network.target line, I think the fix is to use After=network-online.target instead.

From https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/:

network.target has very little meaning during start-up. It only indicates that the network management stack is up after it has been reached. Whether any network interfaces are already configured when it is reached is undefined. [...]

network-online.target is a target that actively waits until the nework is "up", where the definition of "up" is defined by the network management software. Usually it indicates a configured, routable IP address of some kind. Its primary purpose is to actively delay activation of services until the network is set up. [...]

Steps to reproduce

Reboot the server, watch logs for maddy startup failures.

I tested with the network-online target too, and after server reboot maddy started on the first try.

Configuration file

In maddy.conf, I have a line that sets a specific IP to bind to:

local_ip 111.111.111.111
@cuu508 cuu508 added the bug Something isn't working. label Aug 13, 2023
cuu508 added a commit to cuu508/maddy that referenced this issue Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant