Skip to content

Commit

Permalink
always kill self on ctrl+c
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Aug 22, 2024
1 parent 3fd8b3c commit 7da8bf3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions py4web/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,12 +1717,10 @@ def start_server(kwargs):
server_config["server"] = "gunicorn"

# Catch interrupts like Ctrl-C if needed
def stop_then_kill(sig, grame):
os.kill(os.getpid(), signal.SIGTERM)
time.sleep(2)
def kill_all(sig, grame):
os.kill(os.getpid(), signal.SIGKILL)

signal.signal(signal.SIGINT, stop_then_kill)
signal.signal(signal.SIGINT, kill_all)

adapter = server_adapters.available.get(server_config["server"])
params["server"] = adapter or server_config["server"]
Expand Down

0 comments on commit 7da8bf3

Please sign in to comment.