Skip to content

Commit

Permalink
merge from cloud worker init
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Kuo (Danswer) committed Dec 18, 2024
2 parents 65b5abb + e8e0745 commit 853eff2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
5 changes: 0 additions & 5 deletions backend/onyx/background/celery/apps/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from onyx.utils.logger import setup_logger
from onyx.utils.variable_functionality import fetch_versioned_implementation
from shared_configs.configs import IGNORED_SYNCING_TENANT_LIST
from shared_configs.configs import MULTI_TENANT

logger = setup_logger(__name__)

Expand Down Expand Up @@ -154,10 +153,6 @@ def on_beat_init(sender: Any, **kwargs: Any) -> None:
SqlEngine.set_app_name(POSTGRES_CELERY_BEAT_APP_NAME)
SqlEngine.init_engine(pool_size=2, max_overflow=0)

# Startup checks are not needed in multi-tenant case
if MULTI_TENANT:
return

app_base.wait_for_redis(sender, **kwargs)


Expand Down
9 changes: 5 additions & 4 deletions backend/onyx/background/celery/apps/heavy.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
SqlEngine.set_app_name(POSTGRES_CELERY_WORKER_HEAVY_APP_NAME)
SqlEngine.init_engine(pool_size=4, max_overflow=12)

# Startup checks are not needed in multi-tenant case
if MULTI_TENANT:
return

app_base.wait_for_redis(sender, **kwargs)
app_base.wait_for_db(sender, **kwargs)
app_base.wait_for_vespa(sender, **kwargs)

# Less startup checks in multi-tenant case
if MULTI_TENANT:
return

app_base.on_secondary_worker_init(sender, **kwargs)


Expand Down
9 changes: 5 additions & 4 deletions backend/onyx/background/celery/apps/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
SqlEngine.set_app_name(POSTGRES_CELERY_WORKER_INDEXING_APP_NAME)
SqlEngine.init_engine(pool_size=sender.concurrency, max_overflow=sender.concurrency)

# Startup checks are not needed in multi-tenant case
if MULTI_TENANT:
return

app_base.wait_for_redis(sender, **kwargs)
app_base.wait_for_db(sender, **kwargs)
app_base.wait_for_vespa(sender, **kwargs)

# Less startup checks in multi-tenant case
if MULTI_TENANT:
return

app_base.on_secondary_worker_init(sender, **kwargs)


Expand Down
8 changes: 5 additions & 3 deletions backend/onyx/background/celery/apps/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:

SqlEngine.set_app_name(POSTGRES_CELERY_WORKER_LIGHT_APP_NAME)
SqlEngine.init_engine(pool_size=sender.concurrency, max_overflow=8)
# Startup checks are not needed in multi-tenant case
if MULTI_TENANT:
return

app_base.wait_for_redis(sender, **kwargs)
app_base.wait_for_db(sender, **kwargs)
app_base.wait_for_vespa(sender, **kwargs)

# Less startup checks in multi-tenant case
if MULTI_TENANT:
return

app_base.on_secondary_worker_init(sender, **kwargs)


Expand Down
8 changes: 4 additions & 4 deletions backend/onyx/background/celery/apps/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def on_worker_init(sender: Any, **kwargs: Any) -> None:
SqlEngine.set_app_name(POSTGRES_CELERY_WORKER_PRIMARY_APP_NAME)
SqlEngine.init_engine(pool_size=8, max_overflow=0)

# Startup checks are not needed in multi-tenant case
if MULTI_TENANT:
return

app_base.wait_for_redis(sender, **kwargs)
app_base.wait_for_db(sender, **kwargs)
app_base.wait_for_vespa(sender, **kwargs)

# Less startup checks in multi-tenant case
if MULTI_TENANT:
return

logger.info("Running as the primary celery worker.")

# This is singleton work that should be done on startup exactly once
Expand Down

0 comments on commit 853eff2

Please sign in to comment.