-
-
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
Preserve systemd provided socket after shutdown #20490
Comments
Have you tried using kill -1 to restart gitea? |
I could, but why? |
from what I learned, a reference from golang/go#11826 (comment):
|
Isn't it normal to unlink a inactive socket, indicating it is not available? What other options are there? |
Leave it alone. https://www.freedesktop.org/software/systemd/man/systemd.socket.html again,
|
Interesting, yeah they mention it multiple times on that link:
Unrelated to gitea, but normally, what I do in my apps is unlink,create and chmod 666 a socket on start, and do nothing with it on shutdown. |
further explanation on how it breaks "systemctl restart":
under such circumstances, users would have to first restart gitea.socket, then gitea.service. moreover, the gitea.service can't be automatically activated on incoming request, which is what systemd.socket is designed for. |
no, this is not about using ipc file, this is about using systemd.socket. it's two seperate(basically) things to consider. of course a socket file would ultimately be unlinked. but in this case, shouldn't be done by application. it happens when user explicitly stops gitea.socket, not gitea.service. |
any thoughts? |
By default Gitea will always unlink any sockets that are provided using the `LISTEN_FDS` environment variable. This is because it uses this variable to handle passing when it is doing a graceful restart. However, this same mechanism is used by systemd - which explicitly expects that passed in sockets should not be unlinked by the receiving process. This PR adjusts Gitea's graceful restart mechanism to use an additional environment variable which tracks if a listening socket was opened by Gitea - and therefore should be unlinked on shutdown by Gitea. Fix #20490 Co-authored-by: zeripath <art27@cantab.net>
By default Gitea will always unlink any sockets that are provided using the `LISTEN_FDS` environment variable. This is because it uses this variable to handle passing when it is doing a graceful restart. However, this same mechanism is used by systemd - which explicitly expects that passed in sockets should not be unlinked by the receiving process. This PR adjusts Gitea's graceful restart mechanism to use an additional environment variable which tracks if a listening socket was opened by Gitea - and therefore should be unlinked on shutdown by Gitea. Fix go-gitea#20490 Co-authored-by: zeripath <art27@cantab.net>
Description
I struggle to understand why gitea unlinks the socket file on shutdown (L171):
gitea/modules/graceful/net_unix.go
Lines 166 to 174 in a701fd3
I believe this is unwanted behavior since it breaks
systemctl restart gitea
when using socket activation.Gitea Version
a701fd3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Database
PostgreSQL
The text was updated successfully, but these errors were encountered: