{"action":"opened","issue":{"url":"https://api.github.com/repos/go-gitea/gitea/issues/5035","repository_url":"https://api.github.com/repos/go-gitea/gitea","labels_url":"https://api.github.com/repos/go-gitea/gitea/issues/5035/labels{/name}","comments_url":"https://api.github.com/repos/go-gitea/gitea/issues/5035/comments","events_url":"https://api.github.com/repos/go-gitea/gitea/issues/5035/events","html_url":"https://github.com/go-gitea/gitea/issues/5035","id":367530971,"node_id":"MDU6SXNzdWUzNjc1MzA5NzE=","number":5035,"title":"Systemd socket activation support","user":{"login":"DevelAngel707","id":2845817,"node_id":"MDQ6VXNlcjI4NDU4MTc=","avatar_url":"https://avatars0.githubusercontent.com/u/2845817?v=4","gravatar_id":"","url":"https://api.github.com/users/DevelAngel707","html_url":"https://github.com/DevelAngel707","followers_url":"https://api.github.com/users/DevelAngel707/followers","following_url":"https://api.github.com/users/DevelAngel707/following{/other_user}","gists_url":"https://api.github.com/users/DevelAngel707/gists{/gist_id}","starred_url":"https://api.github.com/users/DevelAngel707/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevelAngel707/subscriptions","organizations_url":"https://api.github.com/users/DevelAngel707/orgs","repos_url":"https://api.github.com/users/DevelAngel707/repos","events_url":"https://api.github.com/users/DevelAngel707/events{/privacy}","received_events_url":"https://api.github.com/users/DevelAngel707/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-07T07:58:02Z","updated_at":"2018-10-07T07:58:02Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n    1. Please speak English, this is the language all of us can speak and write.\r\n    2. Please ask questions or configuration/deploy problems on our Discord \r\n       server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io).\r\n    3. Please take a moment to check that your issue doesn't already exist.\r\n    4. Please give all relevant information below for bug reports, because \r\n       incomplete details will be handled as an invalid report.\r\n-->\r\n- Gitea version (or commit ref): 1.5.1\r\n- Git version: 2.18.0\r\n- Operating system: Gentoo on ARM64 (Raspberry Pi 3B)\r\n- Database:\r\n  - [x] PostgreSQL (version 10.4)\r\n  - [ ] MySQL\r\n  - [ ] MSSQL\r\n  - [ ] SQLite\r\n- Can you reproduce the bug at https://try.gitea.io:\r\n  - [ ] Yes (provide example URL)\r\n  - [ ] No\r\n  - [x] Not relevant\r\n\r\n## Description\r\nI 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. \r\n\r\nSystemd has a nice [feature](https://www.freedesktop.org/software/systemd/man/systemd.socket.html) 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.\r\n\r\nMy 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.\r\n\r\n## Solution (Patch)\r\nI 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](https://github.com/DevelAngel707/gentoo-overlay-da707-go/tree/master/www-apps/gitea).\r\n\r\nThere you can find the patch [here](https://github.com/DevelAngel707/gentoo-overlay-da707-go/blob/master/www-apps/gitea/files/gitea-1.5.1-systemd-socket-activation-support.patch): 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.\r\n\r\nThe 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](https://github.com/DevelAngel707/gentoo-overlay-da707-go/blob/95081e6c6eddaba8e4a3f5501c3eb9c57cdc44a8/www-apps/gitea/gitea-1.5.1.ebuild#L15) (lastest version) and moved the content to [folder `vendor/github.com/coreos/go-sytemd`](https://github.com/DevelAngel707/gentoo-overlay-da707-go/blob/95081e6c6eddaba8e4a3f5501c3eb9c57cdc44a8/www-apps/gitea/gitea-1.5.1.ebuild#L35). \r\n\r\nAfter discussion (and first review of patch), I can prepare the commit for socket activation and a pull request."}}
{"actor":{"display_login":"DevelAngel707"}}