Skip to content

Commit 6c30f79

Browse files
committed
Heroku configuration ready
1 parent 862d007 commit 6c30f79

8 files changed

Lines changed: 207 additions & 3 deletions

File tree

Pipfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ pygments = "*"
1313
httpie = "*"
1414
pyyaml = "*"
1515
coreapi-cli = "*"
16+
uwsgi = "*"
17+
django-heroku = "*"
18+
gunicorn = "*"
19+
pipenv-to-requirements = "*"
1620

1721
[dev-packages]
1822

Pipfile.lock

Lines changed: 110 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
release: python manage.py migrate --no-input
2-
web: uwsgi saleor/wsgi/uwsgi.ini
2+
web: gunicorn backend.wsgi

apiconfig/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
For the full list of settings and their values, see
1010
https://docs.djangoproject.com/en/2.1/ref/settings/
1111
"""
12-
12+
import django_heroku
1313
import os
1414

1515
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -147,3 +147,5 @@
147147
# https://docs.djangoproject.com/en/2.1/howto/static-files/
148148

149149
STATIC_URL = '/static/'
150+
151+
django_heroku.settings(locals())

requirements.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
################################################################################
2+
# This requirements file has been automatically generated from `Pipfile` with
3+
# `pipenv-to-requirements`
4+
#
5+
#
6+
# This has been done to maintain backward compatibility with tools and services
7+
# that do not support `Pipfile` yet.
8+
#
9+
# Do NOT edit it directly, use `pipenv install [-d]` to modify `Pipfile` and
10+
# `Pipfile.lock` and then regenerate `requirements*.txt`.
11+
################################################################################
12+
13+
certifi==2018.11.29
14+
chardet==3.0.4
15+
click==7.0
16+
coreapi-cli==1.0.9
17+
coreapi==2.3.3
18+
coreschema==0.0.4
19+
dj-database-url==0.5.0
20+
django-filter==2.0.0
21+
django-heroku==0.3.1
22+
django==2.1.4
23+
djangorestframework==3.9.0
24+
gunicorn==19.9.0
25+
httpie==1.0.2
26+
idna==2.7
27+
itypes==1.1.0
28+
jinja2==2.10
29+
markdown==3.0.1
30+
markupsafe==1.1.0
31+
pbr==5.1.1
32+
pipenv-to-requirements==0.6.1
33+
pipenv==2018.11.26
34+
psycopg2==2.7.6.1
35+
pygments==2.3.0
36+
pytz==2018.7
37+
pyyaml==3.13
38+
requests==2.20.1
39+
uritemplate==3.0.0
40+
urllib3==1.24.1
41+
uwsgi==2.0.17.1
42+
virtualenv-clone==0.4.0
43+
virtualenv==16.1.0
44+
whitenoise==4.1.2

wsgi/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""WSGI config for project.
2+
3+
This module contains the WSGI application used by Django's development server
4+
and any production WSGI deployments. It should expose a module-level variable
5+
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
6+
this application via the ``WSGI_APPLICATION`` setting.
7+
8+
Usually you will have the standard Django WSGI application here, but it also
9+
might make sense to replace the whole Django WSGI application with a custom one
10+
that later delegates to the Django one. For example, you could introduce WSGI
11+
middleware here, or combine a Django application with an application of another
12+
framework.
13+
"""
14+
import os
15+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'apiconfig.settings')
16+
17+
# This application object is used by any WSGI server configured to use this
18+
# file. This includes Django's development server, if the WSGI_APPLICATION
19+
# setting points here.
20+
from django.core.wsgi import get_wsgi_application # noqa
21+
application = get_wsgi_application()
22+
23+
# Apply WSGI middleware here.
24+
# from helloworld.wsgi import HelloWorldApplication
25+
# application = HelloWorldApplication(application)
26+
from .health_check import health_check # noqa
27+
28+
application = health_check(application, '/health/')

wsgi/health_check.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def health_check(application, health_url):
2+
def health_check_wrapper(environ, start_response):
3+
if environ.get('PATH_INFO') == health_url:
4+
start_response('200 OK', [('Content-Type', 'text/plain')])
5+
return []
6+
return application(environ, start_response)
7+
return health_check_wrapper

wsgi/uwsgi.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[uwsgi]
2+
die-on-term = true
3+
http-socket = :$(PORT)
4+
log-format = UWSGI uwsgi "%(method) %(uri) %(proto)" %(status) %(size) %(msecs)ms [PID:%(pid):Worker-%(wid)] [RSS:%(rssM)MB]
5+
master = true
6+
max-requests = 100
7+
memory-report = true
8+
module = apiconfig.wsgi:application
9+
processes = 4
10+
static-map = /static=/app/static

0 commit comments

Comments
 (0)