Skip to content
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

Feature Request: Please consider adding support for starting the container via systemd socket activation #693

Open
felixc opened this issue Jun 30, 2024 · 3 comments

Comments

@felixc
Copy link

felixc commented Jun 30, 2024

It would be wonderful (but not trivial!) to add support for starting the container+server via systemd socket activation. It would allow starting the server on-demand, while leaving it not running most of the time. This is a good match for servers that are rarely used and which shouldn't be left on 24/7 consuming system resources.

Since, to my knowledge, Valheim itself does not support socket activation, support would have to be "grafted on" by using proxies such as systemd-socket-proxyd to intercept and buffer the connection while the container and server are launching. From my reading, I get the impression this is possible, but that the easiest way is to have support built-in to the container image itself -- hence this feature request.

Some prior art on adding support to services that do not natively support socket activation:

General background reading:

Of course, another option would be to ask the upstream game developers for native support...

Would also address #687, as mentioned in the comments.

@ciphersimian
Copy link

#626 (comment)

@lloesche
Copy link
Owner

This all hinges on how Valheim's Windows client behaves when a server doesn't respond within a certain amount of time. It's going to take anywhere from 10 to around 40 seconds for the server to start up, load the world and accept connections. During that time the client's UDP packages wouldn't get any response. Systemd would buffer them and eventually forward to the server, but the client might just assume a server that doesn't respond within seconds to be dead.

@Nicd
Copy link

Nicd commented Jul 18, 2024

I don't use Docker but I'm commenting here since this is one of the discussions I stumbled upon while working on socket activation for my Valheim dedicated server, in the interest that this is somehow useful to you. I ended up writing a small UDP proxy in Node.js (but it could be any language really) to manage the socket. I detailed it all in a blog post at https://blog.nytsoi.net/2024/07/18/valheim-systemd-socket-activation and the code repo is https://git.ahlcode.fi/nicd/valproxy.

The caveat is that as you mentioned, the server takes time to start, and on my server it's not quick enough to respond to the first connection attempt. So the first user will need to connect twice. I deem this acceptable in my use case, which is just a server for some friends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants