Skip to content

Commit

Permalink
Fixes Puppet Forge wsgi application entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
dkliban committed Jan 29, 2016
1 parent 25e4a85 commit 2960d39
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
3 changes: 0 additions & 3 deletions pulp_puppet_plugins/pulp_puppet/forge/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from django.conf.urls import patterns, url
from pulp_puppet.forge.views.releases import ReleasesView, ReleasesPost36View
from pulp.server.db import connection


connection.initialize()

urlpatterns = patterns('',
url(r'^pulp_puppet/forge/([^/]+)/([^/]+)/api/v1/releases.json', ReleasesView.as_view(),
name='post_33_releases'),
Expand Down
35 changes: 34 additions & 1 deletion pulp_puppet_plugins/pulp_puppet/forge/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@
"""

import os
import logging

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pulp_puppet.forge.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
from pulp.server.webservices.application import SaveEnvironWSGIHandler
from pulp.server import initialization, logs


def wsgi_application():
"""
Application factory to create, configure, and return a WSGI application
using the django framework
:return: wsgi application callable
"""
try:
logger = logging.getLogger(__name__)
logs.start_logging()
initialization.initialize()
except initialization.InitializationException, e:
logger.fatal('*************************************************************')
logger.fatal('The Pulp Puppet Forge server failed to start due to the following reasons:')
logger.exception(' ' + e.message)
logger.fatal('*************************************************************')
raise e
except Exception as e:
logger.fatal('*************************************************************')
logger.exception('The Pulp Puppet Forge encountered an unexpected failure during initialization')
logger.fatal('*************************************************************')
raise e

logger.info('*************************************************************')
logger.info('The Pulp Puppet Forge has been successfully initialized')
logger.info('*************************************************************')

return SaveEnvironWSGIHandler(get_wsgi_application())
6 changes: 2 additions & 4 deletions pulp_puppet_plugins/usr/share/pulp/wsgi/puppet_forge.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
from pulp_puppet.forge.wsgi import wsgi_application

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pulp_puppet.forge.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
application = wsgi_application()

0 comments on commit 2960d39

Please sign in to comment.