Try to stop the model if it was loaded when ctrl-c received

This commit is contained in:
Leszek Hanusz 2025-06-03 00:57:55 +02:00
parent b38ec0ec38
commit 142c4eb1a6
2 changed files with 8 additions and 0 deletions

View file

@ -398,6 +398,7 @@ class LlamaServer:
def stop(self):
"""Stop the server process."""
if self.process:
logger.info("Terminating llama-server...")
self.process.terminate()
try:
self.process.wait(timeout=5)

View file

@ -60,6 +60,13 @@ from modules.utils import gradio
def signal_handler(sig, frame):
logger.info("Received Ctrl+C. Shutting down Text generation web UI gracefully.")
# Try to stop the model if loaded
try:
shared.model.stop()
except:
pass
sys.exit(0)