Skip to content

Commit

Permalink
Load gunicorn defaults before overriding with app settings
Browse files Browse the repository at this point in the history
fixes: pulp#4917
  • Loading branch information
sdherr committed Jan 10, 2024
1 parent 78679eb commit a12b15d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/4917.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable the gunicorn applications for pulp-api and pulp-content to load configs from a "gunicorn.conf.py" file.
14 changes: 12 additions & 2 deletions pulpcore/app/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.db import connection
from django.db.utils import InterfaceError, OperationalError
from gunicorn.workers.sync import SyncWorker
from gunicorn.app.base import BaseApplication
from gunicorn.app.base import Application

from pulpcore.app.apps import pulp_plugin_configs

Expand Down Expand Up @@ -80,12 +80,22 @@ def run(self):
self.api_app_status.delete()


class PulpcoreApiApplication(BaseApplication):
class PulpcoreApiApplication(Application):
def __init__(self, options):
self.options = options or {}
super().__init__()

def init(self, *args, **kwargs):
"""
A hook for setting application-specific configs, which we instead do below in load_config
where it's non-overridable.
"""
pass

def load_config(self):
# Load default gunicorn configs, including reading from the default config file.
super().load_config()
# Override with settings that we've specified in the startup script.
[
self.cfg.set(key.lower(), value)
for key, value in self.options.items()
Expand Down
14 changes: 12 additions & 2 deletions pulpcore/content/entrypoint.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import click
from gunicorn.app.base import BaseApplication
from gunicorn.app.base import Application


class PulpcoreContentApplication(BaseApplication):
class PulpcoreContentApplication(Application):
def __init__(self, options):
self.options = options or {}
super().__init__()

def init(self, *args, **kwargs):
"""
A hook for setting application-specific configs, which we instead do below in load_config
where it's non-overridable.
"""
pass

def load_config(self):
# Load default gunicorn configs, including reading from the default config file.
super().load_config()
# Override with settings that we've specified in the startup script.
[
self.cfg.set(key.lower(), value)
for key, value in self.options.items()
Expand Down

0 comments on commit a12b15d

Please sign in to comment.