Skip to content

Commit

Permalink
Switch to gunicorn for serving applications
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Valsecchi authored and pvalsecc committed Feb 3, 2017
1 parent 7f04557 commit 524e892
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 88 deletions.
64 changes: 0 additions & 64 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions acceptance_tests/app/.whiskey/action_hooks/pre-build

This file was deleted.

1 change: 0 additions & 1 deletion acceptance_tests/app/.whiskey/custom_apache.conf

This file was deleted.

1 change: 0 additions & 1 deletion acceptance_tests/app/.whiskey/server_args

This file was deleted.

8 changes: 4 additions & 4 deletions acceptance_tests/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM grahamdumpleton/mod-wsgi-docker:python-3.5
FROM python:3.5
MAINTAINER Camptocamp "[email protected]"

# Doing things in two steps to avoid needing to re-install everything when we do a rebuild
# after changing code

# Step #1 copy only the stuff needed to install the dependencies and run the script
WORKDIR /app
COPY requirements.txt setup.py c2cwsgiutils-0.0.0-py3-none-any.whl /app/
COPY .whiskey /app/.whiskey
RUN mod_wsgi-docker-build
RUN pip install -r requirements.txt

EXPOSE 80

Expand All @@ -22,4 +22,4 @@ ENV DEVELOPMENT 0
COPY . /app
RUN python /app/setup.py install

CMD ["mod_wsgi-docker-start", "application.wsgi"]
CMD ["c2cwsgiutils_run"]
4 changes: 0 additions & 4 deletions acceptance_tests/app/application.wsgi

This file was deleted.

6 changes: 4 additions & 2 deletions c2cwsgiutils/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from pyramid.paster import get_app


def create_application(configfile="/app/production.ini"):
def create_application(configfile=None):
"""
Create a standard WSGI application with the capabilities to use environment variables in the
configuration file (use %(ENV_VAR)s place holders)
:param config: The configuration file to use (relative to root)
:param config: The configuration file to use
:return: The application
"""
if configfile is None:
configfile = os.environ.get('C2CWSGIUTILS_CONFIG', "/app/production.ini")
# Load the logging config without using pyramid to be able to use environment variables in there.
fileConfig(configfile, defaults=os.environ)
return get_app(configfile, 'main', options=os.environ)
7 changes: 7 additions & 0 deletions c2cwsgiutils/wsgi_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Module used by c2cwsgiutils_run.sh to provide a WSGI application when starting gunicorn
"""
from c2cwsgiutils import wsgi


application = wsgi.create_application()
7 changes: 7 additions & 0 deletions c2cwsgiutils_run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [ -z "$GUNICORN_PARAMS" ]
then
GUNICORN_PARAMS="-b :80 --threads 10 --workers 5"
fi
gunicorn $GUNICORN_PARAMS c2cwsgiutils.wsgi_app:application
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages


version = '0.0.2'
version = '0.1.0'

setup(
name='c2cwsgiutils',
Expand Down Expand Up @@ -29,6 +29,7 @@
install_requires=[
'cee_syslog_handler==0.3.4',
'cornice==2.4.0',
'gunicorn==19.6.0',
'netifaces==0.10.5',
'psycopg2==2.6.2',
'pyramid==1.8.1',
Expand All @@ -39,8 +40,12 @@
'zope.interface==4.3.3',
'zope.sqlalchemy==0.7.7',
],
entry_points="""
# -*- Entry points: -*-
""",
entry_points={
'console_scripts': [
]
},
scripts=[
'c2cwsgiutils_run'
]
)

0 comments on commit 524e892

Please sign in to comment.