gunicorn/bin/gunicorn_django
2010-02-01 19:40:59 +01:00

35 lines
776 B
Python
Executable File

#! /usr/bin/env python
# -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
from gunicorn.main import main
__usage__ = "%prog [OPTIONS]"
PROJECT_PATH = os.getcwd()
if not os.path.isfile(os.path.join(PROJECT_PATH, "settings.py")):
print >>sys.stderr, "settings file not found."
sys.exit(1)
PROJECT_NAME = os.path.split(PROJECT_PATH)[-1]
sys.path.insert(0, PROJECT_PATH)
sys.path.append(os.path.join(PROJECT_PATH, os.pardir))
# set environ
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % PROJECT_NAME
def get_app(parser, opts, args):
# django wsgi app
return WSGIHandler()
main(__usage__, get_app)