mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27:10 +00:00
Pass a SIGTERM to tell the uvicorn server to exit and gracefully kill the thread
This commit is contained in:
parent
34d5cd2bd8
commit
4fb8c2c5e1
2 changed files with 7 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
# Standard Packages
|
# Standard Packages
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
from PySide6 import QtGui, QtWidgets
|
from PySide6 import QtGui, QtWidgets
|
||||||
|
@ -21,6 +23,10 @@ class ServerThread(QThread):
|
||||||
def run(self):
|
def run(self):
|
||||||
self.start_server_func()
|
self.start_server_func()
|
||||||
|
|
||||||
|
def exit(self):
|
||||||
|
os.kill(os.getpid(), signal.SIGTERM)
|
||||||
|
super(ServerThread, self).exit()
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow):
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
"""Create Window to Navigate users to the web UI"""
|
"""Create Window to Navigate users to the web UI"""
|
||||||
|
|
|
@ -123,7 +123,7 @@ def run():
|
||||||
|
|
||||||
# Start Application
|
# Start Application
|
||||||
server.start()
|
server.start()
|
||||||
gui.aboutToQuit.connect(server.terminate)
|
gui.aboutToQuit.connect(server.exit)
|
||||||
|
|
||||||
# Close Splash Screen if still open
|
# Close Splash Screen if still open
|
||||||
if system() != "Darwin":
|
if system() != "Darwin":
|
||||||
|
|
Loading…
Reference in a new issue