Re-instate the scheduler for the demo instances (#279)

* For the demo instance, re-instate the scheduler, but infrequently for api updates

- In constants, determine the cadence based on whether it's a demo instance or not
- This allow us to collect telemetry again. This will also allow us to save the chat session

* Conditionally skip updating the index altogether if it's a demo isntance
This commit is contained in:
sabaimran 2023-07-06 11:01:32 -07:00 committed by GitHub
parent 8f36572a9b
commit d688ddf92c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

View file

@ -67,8 +67,10 @@ def configure_routes(app):
app.include_router(web_client)
@schedule.repeat(schedule.every(61).minutes)
def update_search_index():
if not state.demo:
@schedule.repeat(schedule.every(61).minutes)
def update_search_index():
state.search_index_lock.acquire()
state.model = configure_search(state.model, state.config, regenerate=False)
state.search_index_lock.release()

View file

@ -65,7 +65,6 @@ def run():
logger.info("🌘 Starting Khoj")
if not args.gui:
if not state.demo:
# Setup task scheduler
poll_task_scheduler()

View file

@ -41,6 +41,7 @@ from fastapi.responses import StreamingResponse
api = APIRouter()
logger = logging.getLogger(__name__)
# If it's a demo instance, prevent updating any of the configuration.
if not state.demo:
@api.get("/config/data", response_model=FullConfig)