diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 33be536..0000000 --- a/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.pyc -*~ -.DS_Store -local_settings.py diff --git a/README.rst b/README.rst index 96c2b0c..6be3e7c 100644 --- a/README.rst +++ b/README.rst @@ -15,9 +15,22 @@ Usage Run ``./manage.py runcpserver help`` from within your project directory +Apache and mod_proxy +-------------------- +By default runcpserver binds to localhost on port 8088. Another webserver can be used to expose your local CherryPy +instance by proxying requests to the local process. Remember, runcpserver won't serve your static files. + + + ProxyPass /static/ ! + + ProxyPass http://localhost:8088 + ProxyPassRevese http://localhost:8088 + + + Acknowledgements ================ Idea and code snippets borrowed from `Loic d'Anterroches`__, adapted to run as a management command -__ http://www.xhtml.net/scripts/Django-CherryPy-server-DjangoCerise \ No newline at end of file +__ http://www.xhtml.net/scripts/Django-CherryPy-server-DjangoCerise diff --git a/django_cpserver/management/commands/runcpserver.py b/django_cpserver/management/commands/runcpserver.py index 3611273..7d4fbae 100644 --- a/django_cpserver/management/commands/runcpserver.py +++ b/django_cpserver/management/commands/runcpserver.py @@ -115,7 +115,8 @@ def poll_process(pid): try: # poll the process state os.kill(pid, 0) - except OSError, e: + except OSError: + e = sys.exc_info()[1] if e[0] == errno.ESRCH: # process has died return False @@ -139,7 +140,7 @@ def stop_server(pidfile): #process didn't exit cleanly, make one last effort to kill it os.kill(pid, signal.SIGKILL) if poll_process(pid): - raise OSError, "Process %s did not stop." + raise OSError("Process %s did not stop.") os.remove(pidfile) def start_server(options): @@ -153,11 +154,14 @@ def start_server(options): from cherrypy.wsgiserver import CherryPyWSGIServer as Server from django.core.handlers.wsgi import WSGIHandler + app = WSGIHandler() server = Server( (options['host'], int(options['port'])), - WSGIHandler(), + app, int(options['threads']), - options['server_name'] + options['server_name'], + timeout=2, + shutdown_timeout=2 ) if options['ssl_certificate'] and options['ssl_private_key']: server.ssl_certificate = options['ssl_certificate'] @@ -180,7 +184,7 @@ def runcpserver(argset=[], **kwargs): options[k.lower()] = v if "help" in options: - print CPSERVER_HELP + print(CPSERVER_HELP) return if "stop" in options: @@ -203,7 +207,7 @@ def runcpserver(argset=[], **kwargs): fp.close() # Start the webserver - print 'starting server with options %s' % options + print('starting server with options %s' % options) start_server(options) diff --git a/setup.py b/setup.py index 9acc787..cc69d0e 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,31 @@ -from distutils.core import setup - +#from distutils.core import setup +from setuptools import setup +import os, os.path + +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + setup( - name="django_cpserver", - version="0.1", - description="Management commands for serving Django via CherryPy's built-in WSGI server", + name="django-cpserver-op", + version="1.90.0", + description="Management commands for serving Django via CherryPy's built-in WSGI server modified for OpenProximity", author="Peter Baumgartner", author_email="pete@lincolnloop.com", - url="http://lincolnloop.com/blog/2008/mar/25/serving-django-cherrypy/", + url="https://github.com/OpenProximity/django-cpserver", packages=[ "django_cpserver", "django_cpserver.management", "django_cpserver.management.commands", ], -) \ No newline at end of file + license="BSD", + long_description=read("README.rst"), + install_requires=['CherryPy'], + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Framework :: CherryPy", + "Framework :: Django", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + ] +)