mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-26 01:30:20 +01:00
Clean-up Ctrl+C Shutdown (#4802)
This commit is contained in:
parent
0f828ea441
commit
f786aa3caa
@ -4,6 +4,7 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import signal
|
||||||
import site
|
import site
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -27,6 +28,13 @@ else:
|
|||||||
flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
|
flags = f"{' '.join([flag for flag in sys.argv[1:] if flag != '--update'])} {CMD_FLAGS}"
|
||||||
|
|
||||||
|
|
||||||
|
def signal_handler(sig, frame):
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
|
||||||
def is_linux():
|
def is_linux():
|
||||||
return sys.platform.startswith("linux")
|
return sys.platform.startswith("linux")
|
||||||
|
|
||||||
|
12
server.py
12
server.py
@ -21,6 +21,7 @@ matplotlib.use('Agg') # This fixes LaTeX rendering on some systems
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -55,6 +56,17 @@ from modules.models_settings import (
|
|||||||
from modules.utils import gradio
|
from modules.utils import gradio
|
||||||
|
|
||||||
|
|
||||||
|
def signal_handler(sig, frame):
|
||||||
|
logger.info(f"Received Ctrl+C. Shutting down Text generation web UI gracefully")
|
||||||
|
if 'interface' in shared.gradio:
|
||||||
|
shared.gradio['interface'].close()
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
|
||||||
def create_interface():
|
def create_interface():
|
||||||
|
|
||||||
title = 'Text generation web UI'
|
title = 'Text generation web UI'
|
||||||
|
Loading…
Reference in New Issue
Block a user