Open elboulangero opened 3 years ago
Requires makes it so that miniflux won't be started if postgresql is not up: it's a hard requirement. Seems to make sense here, since without postgresql, miniflux can't work and is not functional AFAIK.
It's pretty common these days to run the database on a different machine. I don't know what would be Systemd behavior if Postgresql is not installed voluntary on the same host.
Perhaps Wants
is a better fit: https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants=
It's worth testing.
I reached out on IRC to understand better. So it's not really an issue with the systemd service, and the After=
is enough for ordering from the systemd point of view. BTW, at boot, it all works, because both postgresql
and miniflux
are pulled into multi-user.target.wants, and then systemd can order them properly.
The issue here is that during an apt upgrade transaction, apt will remove and install packages separately, and run their various scripts (preinst, postinst, etc...). The various systemd stop and start commands are done on each package individually. It's not one big "systemd start" with all the services that were upgraded, instead it's one "systemd start" per service. So systemd can't order anything. The order for doing things is instead decided by apt, according to package relations.
So a possible solution would be for miniflux to Depend on postgresql. That will make apt do things in the right order, and it will restart the miniflux service after postgresql.
But that doesn't go well with the use-case you mentioned, ie. having the database on a different machine.
I'm not sure what's the right solution but I'll keep thinking about it. I'll keep this ticket updated.
Thx @mbiebl for the explanations on IRC
Here are the logs of a fresh apt upgrade on my machine (Debian buster):
And here are the corresponding systemd logs:
So what we see clearly with those logs is that systemd tries to start miniflux BEFORE it starts postgresql. The ordering between both is not correct.
Let's look at this file: https://github.com/miniflux/v2/blob/master/packaging/systemd/miniflux.service
Hmmm, so I'm not really sure that it would fix the issue, but I would rather do:
Requires makes it so that miniflux won't be started if postgresql is not up: it's a hard requirement. Seems to make sense here, since without postgresql, miniflux can't work and is not functional AFAIK.
But I can't be sure that such a change would fix the issue at hand here.
Any thought?