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

Add shutdown if idle feature to save resources #687

Open
mrskizzex opened this issue Jun 1, 2024 · 1 comment
Open

Add shutdown if idle feature to save resources #687

mrskizzex opened this issue Jun 1, 2024 · 1 comment

Comments

@mrskizzex
Copy link

mrskizzex commented Jun 1, 2024

Would it be possible to add either a feature in the title as an environmental variable or simply add a feature where you can add your own cron entry?

I crudely edited valheim's user crontab and added:

*/15 * * * * /usr/local/bin/valheim-is-idle && sleep 600 && /usr/local/bin/valheim-is-idle && /usr/local/bin/supervisorctl stop valheim-server

which works but It will probably not survive container updates.

I exposed supervisor page behind 2fa auth to my friends who can start the server if needed but I want to also shut down the server if there is no one on the server for more than 15-30 minutes to save resources.

@lloesche
Copy link
Owner

lloesche commented Jun 23, 2024

You can shut it down when idle, the question is how do you start it back up when a client connects? You would need some sort of UDP listener/socket handler that waits for incoming clients, puts them in some sort of waiting state while the server starts, so the Windows client doesn't timeout, and then hand over the connection to the Valheim server. You could also try something like systemd socket activation and maybe it would work out. Depends on how the client behaves when the server doesn't react immediately. For TCP services that's easier as you can delay the handshake. For UDP I'm guessing the client would just assume that its packets got lost fairly quickly. So you'd likely have to implement parts of the Valheim server protocol.

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

2 participants