Skip to content

Commit

Permalink
Add settings to allow detaching integrations server (#3203)
Browse files Browse the repository at this point in the history
To run a detached integrations server:
1. Set env var `DETACHED_INTEGRATIONS_SERVER=True`
2. Run engine with the `integrations_urls.py` root url conf
(e.g. `ROOT_URLCONF=engine.integrations_urls python manage.py runserver
0.0.0.0:8081`)
  • Loading branch information
matiasb authored Oct 26, 2023
1 parent a1a318c commit 11259de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 9 additions & 0 deletions engine/engine/integrations_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import URLPattern, URLResolver, include, path

from .urls import paths_to_work_even_when_maintenance_mode_is_active

urlpatterns: list[URLPattern | URLResolver] = paths_to_work_even_when_maintenance_mode_is_active

urlpatterns += [
path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")),
]
12 changes: 8 additions & 4 deletions engine/engine/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@
"""
from django.conf import settings
from django.conf.urls.static import static
from django.urls import include, path
from django.urls import URLPattern, URLResolver, include, path

from .views import HealthCheckView, MaintenanceModeStatusView, ReadinessCheckView, StartupProbeView

paths_to_work_even_when_maintenance_mode_is_active = [
paths_to_work_even_when_maintenance_mode_is_active: list[URLPattern | URLResolver] = [
path("", HealthCheckView.as_view()),
path("health/", HealthCheckView.as_view()),
path("ready/", ReadinessCheckView.as_view()),
path("startupprobe/", StartupProbeView.as_view()),
path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")),
path("api/internal/v1/maintenance-mode-status", MaintenanceModeStatusView.as_view()),
]

urlpatterns = [
if not settings.DETACHED_INTEGRATIONS_SERVER:
paths_to_work_even_when_maintenance_mode_is_active += [
path("integrations/v1/", include("apps.integrations.urls", namespace="integrations")),
]

urlpatterns: list[URLPattern | URLResolver] = [
*paths_to_work_even_when_maintenance_mode_is_active,
path("api/gi/v1/", include("apps.api_for_grafana_incident.urls", namespace="api-gi")),
path("api/internal/v1/", include("apps.api.urls", namespace="api-internal")),
Expand Down
4 changes: 3 additions & 1 deletion engine/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class DatabaseTypes:
},
}

ROOT_URLCONF = "engine.urls"
ROOT_URLCONF = os.environ.get("ROOT_URLCONF", "engine.urls")

TEMPLATES = [
{
Expand Down Expand Up @@ -831,3 +831,5 @@ class BrokerTypes:
ZVONOK_POSTBACK_STATUS = os.getenv("ZVONOK_POSTBACK_STATUS", "status")
ZVONOK_POSTBACK_USER_CHOICE = os.getenv("ZVONOK_POSTBACK_USER_CHOICE", None)
ZVONOK_POSTBACK_USER_CHOICE_ACK = os.getenv("ZVONOK_POSTBACK_USER_CHOICE_ACK", None)

DETACHED_INTEGRATIONS_SERVER = getenv_boolean("DETACHED_INTEGRATIONS_SERVER", default=False)

0 comments on commit 11259de

Please sign in to comment.