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

Keep server state on daemon restart #1270

Open
PolarianDev opened this issue Aug 18, 2023 · 4 comments
Open

Keep server state on daemon restart #1270

PolarianDev opened this issue Aug 18, 2023 · 4 comments

Comments

@PolarianDev
Copy link

Is your feature request related to a problem? Please describe.
Currently there is only a boolean method of starting servers when pufferpanel is restarted:

  • Server is stopped and not started after reboot
  • Server is automatically started after reboot

However this is awkward, because there are times you only want the server started if the server was started before the restart, or keep it off if the server was off before the restart, in other words "keeping the server state".

Describe the solution you'd like
By default:

  • If the server is off when the daemon is reloaded, keep the server off
  • If the server is on when the daemon is reloaded, keep the server on
  • Preserve the option to always start a server whether it was off or on when the daemon restarts

Describe alternatives you've considered
N/A

Additional context
N/A

@LordRalex
Copy link
Member

This is pretty hard to do, because process tracking and making things "zombies" is a dangerous game. Generally, it is not safe to have "zombie" processes, especially ones which are as large as a game server. Hooking back into a process is also generally not trivial, and not safe.

That said, this is easier for docker, but it would be hard to know when "we" should actually kill servers (i.e you want the server off to do a reboot of the machine, or you are doing larger maintenance)

systemctl doesn't let us do that well, because of how both states are.

@PolarianDev
Copy link
Author

I do not know how this is a bad thing, currently pufferpanel manages whether a server is on or off and has said state for it.

When SIGTERM is received, all servers are shutdown and their state stored (were they on or off before the restart) in the database, and then the daemon gracefully shuts down too.

When the daemon is started, the states are fetched and those who were on before the server shutdown and started again.

I see no reason for why this couldn't be implemented.

@LordRalex
Copy link
Member

The state is just "does the PID exist". It's not persisted anywhere currently, nor does the panel even know of it. This is a node-level thing, not a panel. Nodes don't have access to a db.

(That said, I did originally read it as keeping servers running while a daemon was restarted, so my comments aren't fully accurate)

@PolarianDev
Copy link
Author

The state is just "does the PID exist". It's not persisted anywhere currently, nor does the panel even know of it. This is a node-level thing, not a panel. Nodes don't have access to a db.

(That said, I did originally read it as keeping servers running while a daemon was restarted, so my comments aren't fully accurate)

Well an ugly way to do this is a node dumps the current active servers to a json file until it is started again.

But it protocol used to communicate between daemon and panel would need to be updated, on shutdown a daemon tells the panel the state of all the servers on said node, then on daemon start it calls back asking for what servers need to be started.

But this is not a quick and easy way to implement said feature.

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