-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
systemd: gitea.service not started after database upgrade #15866
Comments
|
We had |
I think there's nothing stopping us from having a Requires and After for the same value. I suspect the problem is that without the After the mysqld.service doesn't know that it needs to restart the service. All systemd knew is that it needed to stop the service because a Required dependency no longer existed. I guess we need to know the semantics of Requires, Wants and After. My suspicion is that there are subtle implications of these and that Requires won't start a required service and will shutdown if a Requires service is shutdown. Wants will start the wanted service and will shutdown if the wanted service shutsdown. Whereas After will tell the service that it comes after that it should be started after that service is started. One test of that theory would be to restart the network.target and see if Gitea is restarted after that. |
One particular interesting comment I found on above stackexchange question is:
This should be testable by creating 2 units with a |
@silverwind Oh wow thanks for the report, you saved me hours of debugging on my instance, where the same happened the last two days.. |
I ran into the same issue some time age. This is what resolved it for me
|
OK so it sounds like my suspicion above (#15866 (comment)) is correct and if we change our suggested definition to include In fact it's notable that the lines below regarding socket activation actually suggest this:
|
If the gitea service is stopped because of the db going down it needs an `After=db.service` to ensure it is restarted in addition to the `Requires=db.service` to ensure that the db is started before gitea is started. Fix go-gitea#15866 Signed-off-by: Andrew Thornton <art27@cantab.net>
If the gitea service is stopped because of the db going down it needs an `After=db.service` to ensure it is restarted in addition to the `Requires=db.service` to ensure that the db is started before gitea is started. Fix #15866 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reopen per #15881 (comment) |
Doesn't work for me either, simple test: /etc/systemd/system/unit1.service [Unit]
Description=unit1
Requires=unit2.service
After=unit2.service
[Service]
ExecStart=ping 127.0.0.1
ExecStop=kill -- $MAINPID
StandardOutput=file:/dev/null
[Install]
WantedBy=multi-user.target /etc/systemd/system/unit2.service [Unit]
Description=unit2
[Service]
ExecStart=ping 127.0.0.1
ExecStop=kill -- $MAINPID
StandardOutput=file:/dev/null
[Install]
WantedBy=multi-user.target systemctl daemon-reload
systemctl start unit1 unit2
systemctl stop unit2
systemctl start unit2
systemctl status unit1
# Active: inactive (dead) Putting |
I think systemd can not provide a solution and we're better off using |
Here is my working
|
Yes, it works without
|
Related systemd issue: systemd/systemd#19626 |
`Requires=` has the behaviour of stopping `gitea.service` when the database is stopped but not bringing it up again after the database is started again. Use `Wants=` to define a weak requirement instead, meaning `gitea.service` will be kept running when the database is stopped, which is not an issue because gitea will just reconnect later on. Fixes: go-gitea#15866
`Requires=` has the behaviour of stopping `gitea.service` when the database is stopped but not bringing it up again after the database is started again. Use `Wants=` to define a weak requirement instead, meaning `gitea.service` will be kept running when the database is stopped, which is not an issue because gitea will just reconnect later on. Fixes: #15866 Co-authored-by: zeripath <art27@cantab.net>
If the gitea service is stopped because of the db going down it needs an `After=db.service` to ensure it is restarted in addition to the `Requires=db.service` to ensure that the db is started before gitea is started. Fix go-gitea#15866 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
`Requires=` has the behaviour of stopping `gitea.service` when the database is stopped but not bringing it up again after the database is started again. Use `Wants=` to define a weak requirement instead, meaning `gitea.service` will be kept running when the database is stopped, which is not an issue because gitea will just reconnect later on. Fixes: go-gitea#15866 Co-authored-by: zeripath <art27@cantab.net>
In the systemd service we recommend a
Requires=
dependency, but it seems this causes a issue with the service not being started back up whenapt
upgrades the database dependency. I observed the following sequence with such a configuration during a unattended APT upgrade ofmysql.service
on Ubuntu 20.04.2 using systemd 245:Essentially
gitea.service
is not started up again after the database upgrade for unknown reason.I don't fully understand why systemd would not bring up
gitea.service
in such a case, but I think we may want to consider usingWants=
instead ofRequires=
to indicate a "weak" dependency which may help in such a case, or find out what systemd exactly does here.https://unix.stackexchange.com/questions/375091 sounds like the same issue but I don't think the solution is acceptable.
The text was updated successfully, but these errors were encountered: