bugy / script-server

Web UI for your scripts with execution management
Other
1.59k stars 247 forks source link

Feature request: support clean shutdown also on SIGTERM #736

Open rwalkerands opened 7 months ago

rwalkerands commented 7 months ago

docker/podman stop script-server sends first SIGTERM, then, after a timeout, SIGKILL.

script-server seems to ignore SIGTERM, so docker/podman sends SIGKILL after the timeout.

I see that ./src/web/server.py/intercept_stop_when_running_scripts() configures a handler for SIGINT that will do a clean shutdown as long as there are no currently-running scripts.

Would it be possible to do a clean shutdown on SIGTERM also? It could be like the existing behaviour for SIGINT except (I guess) acting as though the user answered n to the question Do you want to stop server anyway?.

bugy commented 7 months ago

Hi @rwalkerands, thanks for reporting. I'm not sure what is the problem. In my understanding, SIGINT is needed for script server only to ask confirmation from a user. If such confirmation is not needed, a signal (SIGTERM) should be propagated to all children processes. So that it's the responsibility of the children processes to handle SIGTERM properly. Could you confirm, that if there are no running scripts, Script server stops on SIGTERM? Or you mean, that even in this case, SIGTERM is ignored?

rwalkerands commented 7 months ago

I'm getting this:

$ podman stop script-server
WARN[0010] StopSignal SIGTERM failed to stop container script-server in 10 seconds, resorting to SIGKILL
script-server