pufferpanel / pufferpanel

PufferPanel is an open source game server management panel, designed for both small networks and personal use

Home Page:https://pufferpanel.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keep server state on daemon restart

PolarianDev opened this issue · comments

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

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.

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.

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)

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.