Allow starting khoj in non-GUI mode without config file instantiated

- Start khoj server (in non-GUI mode) without needing config file
  already instantiated.
  - But throw warning to configure khoj to use it
- This allows plugins to configure the app via the /config/data APIs
- To be used by the Khoj obsidian plugin to configure markdown content
  in khoj
This commit is contained in:
Debanjum Singh Solanky 2023-01-03 21:36:59 -03:00
parent 52664dd96c
commit 9d31988f42
2 changed files with 3 additions and 2 deletions

View file

@ -26,9 +26,10 @@ logger = logging.getLogger(__name__)
def configure_server(args, required=False):
if args.config is None:
if required:
print('Exiting as Khoj is not configured. Configure the application to use it.')
logger.error(f'Exiting as Khoj is not configured.\nConfigure it via GUI or by editing {state.config_file}.')
sys.exit(1)
else:
logger.warn(f'Khoj is not configured.\nConfigure it via khoj GUI, plugins or by editing {state.config_file}.')
return
else:
state.config = args.config

View file

@ -77,7 +77,7 @@ def run():
# Setup task scheduler
poll_task_scheduler()
# Start Server
configure_server(args, required=True)
configure_server(args, required=False)
start_server(app, host=args.host, port=args.port, socket=args.socket)
else:
# Setup GUI