Skip to content

Commit b188d6d

Browse files
authored
Merge pull request #4 from Never-Over/fixes-celery-render
Fixes for Celery on Render [0.0.20]
2 parents 76db43d + c103d48 commit b188d6d

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

bridge/cli/init/templates/render__yaml.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
envVars:
1111
- key: BRIDGE_PLATFORM
1212
value: render
13+
- key: BRIDGE_PROJECT_NAME
14+
value: {service_name}
1315
- key: SECRET_KEY
1416
generateValue: true
1517
- key: WEB_CONCURRENCY
@@ -37,6 +39,8 @@
3739
envVars:
3840
- key: BRIDGE_PLATFORM
3941
value: render
42+
- key: BRIDGE_PROJECT_NAME
43+
value: {service_name}
4044
- key: SECRET_KEY
4145
generateValue: true
4246
- key: TASK_CONCURRENCY

bridge/framework/django.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def configure_allowed_hosts(self, platform: Platform) -> None:
5353
log_warning(
5454
"ALLOWED_HOSTS already configured and non-empty; overwriting configuration."
5555
)
56-
self.framework_locals["ALLOWED_HOSTS"] = ["*.onrender.com", "localhost"]
56+
self.framework_locals["ALLOWED_HOSTS"] = [".onrender.com", "localhost"]
5757

5858
def configure_debug(self, platform: Platform) -> None:
5959
if platform != Platform.LOCAL:

bridge/service/celery.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
# NOTE: This file is used in both local and remote environments.
2+
# resolve_project_dir() is not guaranteed to work in remote environments,
3+
# so the project_name can be set by an environment variable.
4+
15
import os
26

37
from celery import Celery
48

59
from bridge.utils.filesystem import resolve_project_dir
610

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

1020
# Set the default Django settings module for the 'celery' program.
1121
os.environ.setdefault("DJANGO_SETTINGS_MODULE", f"{project_name}.settings")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python-bridge"
3-
version = "0.0.19"
3+
version = "0.0.20"
44
authors = [
55
{ name="Caelean Barnes", email="[email protected]" },
66
{ name="Evan Doyle", email="[email protected]" },

0 commit comments

Comments
 (0)