-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #342 from uktrade/develop
Merge outstanding PRs for DBT platform
- Loading branch information
Showing
7 changed files
with
101 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
web: python manage.py collectstatic --noinput && python manage.py distributed_migrate --noinput && waitress-serve --port=$PORT conf.wsgi:application | ||
web: python manage.py collectstatic --noinput && python manage.py distributed_migrate --noinput && gunicorn conf.wsgi:application --config conf/gunicorn.py --bind 0.0.0.0:$PORT --worker-connections 1000 | ||
celery_worker: celery -A conf worker -l info | ||
celery_beat: celery -A conf beat -l info -S django | ||
celery_beat: celery -A conf beat -l info -S django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from psycogreen.gevent import patch_psycopg | ||
|
||
|
||
def post_fork(server, worker): | ||
patch_with_psycogreen_gevent() | ||
worker.log.info("Enabled async Psycopg2") | ||
|
||
|
||
def patch_with_psycogreen_gevent(): | ||
patch_psycopg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import pytest | ||
import os | ||
import logging | ||
from unittest.mock import patch | ||
from gevent.server import StreamServer | ||
from conf.gunicorn import post_fork | ||
from gunicorn.workers.ggevent import GeventWorker | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class dotdict(dict): | ||
"""dot.notation access to dictionary attributes""" | ||
|
||
__getattr__ = dict.get | ||
__setattr__ = dict.__setitem__ | ||
__delattr__ = dict.__delitem__ | ||
|
||
|
||
@pytest.fixture | ||
def worker(): | ||
my_dict = { | ||
"max_requests": 1000, | ||
"max_requests_jitter": 10, | ||
"umask": 22, | ||
"worker_tmp_dir": "/tmp", | ||
"uid": os.geteuid(), | ||
"gid": os.getegid(), | ||
"worker_connections": 1000, | ||
} | ||
cfg_dict = dotdict(my_dict) | ||
|
||
worker = GeventWorker( | ||
log=logger, | ||
age=1, | ||
ppid=9999, | ||
sockets=[], | ||
app="directory_forms_api", | ||
timeout=30, | ||
cfg=cfg_dict, | ||
) | ||
return worker | ||
|
||
|
||
@pytest.fixture | ||
def server(): | ||
def handler(): | ||
return None | ||
|
||
server = StreamServer( | ||
listener=("0.0.0.0:8020"), | ||
handle=handler, | ||
) | ||
return server | ||
|
||
|
||
@patch("conf.gunicorn.patch_with_psycogreen_gevent") | ||
def test_post_fork(mock_patch_with_psycogreen_gevent, worker, server): | ||
post_fork(server, worker) | ||
mock_patch_with_psycogreen_gevent.assert_called_once() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
setuptools<72 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters