From d1b2037676d010c003b46e35e47067cb58ae4bbc Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 1 May 2024 13:53:34 +0530 Subject: [PATCH 1/7] Shutdown the scheduler when the application is exiting --- src/khoj/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/khoj/main.py b/src/khoj/main.py index 4a9593af..40b449d7 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -6,6 +6,7 @@ from contextlib import redirect_stdout import logging import io import os +import atexit import sys import locale @@ -93,6 +94,11 @@ from khoj.utils.cli import cli from khoj.utils.initialization import initialization +def shutdown_scheduler(): + logger.info("🌑 Shutting down Khoj") + state.scheduler.shutdown() + + def run(should_start_server=True): # Turn Tokenizers Parallelism Off. App does not support it. os.environ["TOKENIZERS_PARALLELISM"] = "false" @@ -158,9 +164,8 @@ def run(should_start_server=True): # If the server is started through gunicorn (external to the script), don't start the server if should_start_server: start_server(app, host=args.host, port=args.port, socket=args.socket) - - # Teardown - state.scheduler.shutdown() + # Teardown + shutdown_scheduler() def set_state(args): @@ -202,3 +207,4 @@ if __name__ == "__main__": run() else: run(should_start_server=False) + atexit.register(shutdown_scheduler) From c30ba2e55154835db3e14dbac71383fe5305146d Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 1 May 2024 13:54:59 +0530 Subject: [PATCH 2/7] Set subject dynamically when creating new tasks, and make some minor improvments to the automations UI --- src/khoj/interface/web/config_automation.html | 86 +++++++++++++------ src/khoj/routers/api.py | 8 +- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/src/khoj/interface/web/config_automation.html b/src/khoj/interface/web/config_automation.html index 1b067996..902e7949 100644 --- a/src/khoj/interface/web/config_automation.html +++ b/src/khoj/interface/web/config_automation.html @@ -5,12 +5,11 @@

Automate Automate -
+

-

Automations