Skip to content

Commit

Permalink
Merge pull request #4 from Never-Over/fixes-celery-render
Browse files Browse the repository at this point in the history
Fixes for Celery on Render [0.0.20]
  • Loading branch information
emdoyle authored Apr 9, 2024
2 parents 76db43d + c103d48 commit b188d6d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bridge/cli/init/templates/render__yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
envVars:
- key: BRIDGE_PLATFORM
value: render
- key: BRIDGE_PROJECT_NAME
value: {service_name}
- key: SECRET_KEY
generateValue: true
- key: WEB_CONCURRENCY
Expand Down Expand Up @@ -37,6 +39,8 @@
envVars:
- key: BRIDGE_PLATFORM
value: render
- key: BRIDGE_PROJECT_NAME
value: {service_name}
- key: SECRET_KEY
generateValue: true
- key: TASK_CONCURRENCY
Expand Down
2 changes: 1 addition & 1 deletion bridge/framework/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def configure_allowed_hosts(self, platform: Platform) -> None:
log_warning(
"ALLOWED_HOSTS already configured and non-empty; overwriting configuration."
)
self.framework_locals["ALLOWED_HOSTS"] = ["*.onrender.com", "localhost"]
self.framework_locals["ALLOWED_HOSTS"] = [".onrender.com", "localhost"]

def configure_debug(self, platform: Platform) -> None:
if platform != Platform.LOCAL:
Expand Down
12 changes: 11 additions & 1 deletion bridge/service/celery.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# NOTE: This file is used in both local and remote environments.
# resolve_project_dir() is not guaranteed to work in remote environments,
# so the project_name can be set by an environment variable.

import os

from celery import Celery

from bridge.utils.filesystem import resolve_project_dir

# Discover the correct project name
project_name = resolve_project_dir().name
if "BRIDGE_PROJECT_NAME" in os.environ:
# For remote environments, the project name is set by the environment
# since our strategy of reading the current working directory may not work
project_name = os.environ["BRIDGE_PROJECT_NAME"]
else:
# For local environments, we can resolve the project directory by looking at cwd
project_name = resolve_project_dir().name

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{project_name}.settings")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "python-bridge"
version = "0.0.19"
version = "0.0.20"
authors = [
{ name="Caelean Barnes", email="caeleanb@gmail.com" },
{ name="Evan Doyle", email="evanmdoyle@gmail.com" },
Expand Down

0 comments on commit b188d6d

Please sign in to comment.