Systemd socket activation support #5035
Labels
type/feature
Completely new functionality. Can only be merged if feature freeze is not active.
type/proposal
The new feature has not been accepted yet but needs to be discussed first.
Description
I have a little home webserver with an ARM64 Raspberry PI 3B with Gentoo Linux where I run services like Nextcloud, Gitea, DjangoCMS, Prosody IM. The webserver nginx handles the HTTP (port 80) and HTTPS (port 443) connections using Let's encrypt certificates. I prefer filesystem sockets to let nginx communicate with other web applications like Gitea. But systemd socket activation works also with network sockets.
Systemd has a nice feature to start these web applications only when they are needed. To be able to use that feature, socket activation support is needed in the web application. DjangoCMS, for example, will shut down after 10 minutes without interaction to save resources. When a new connection arrives in nginx, DjangoCMS service will be started again. It would be nice to use that feature with Gitea, too.
My gitea.service file looks similar to the contrib version. I created a gitea.socket file which defines an unix filesystem socket, thus [server] PROTOCOL and HTTP_ADDR is not needed in settings.
Solution (Patch)
I patched the 1.5.1 version to integrate the systemd socket activation support. But I think, it needs some discussion before bringing it upstream. I have taken the www-apps/gitea 1.4.3 ebuild from the gentoo repository, which is used by the Gentoo portage package manager, and have modified it to fetch version 1.5.1 and integrate the patch. I pushed all changes to my portage overlay repository for gitea.
There you can find the patch here: Before doing the switch, the systemd socket activation is asked for listeners
activation.Listeners()
. If it does not return an error, at least one listener is defined and socket activation is used. If it returns an error code, do the normal switch statement as before.The systemd socket activation needs the vendor code for
github.com/coreos/go-systemd/activation
. No further dependencies are needed, as I noticed. In my gentoo ebuild, I pull the go-systemd version 17 (lastest version) and moved the content to foldervendor/github.com/coreos/go-sytemd
.After discussion (and first review of patch), I can prepare the commit for socket activation and a pull request.
The text was updated successfully, but these errors were encountered: