Skip to content

Commit

Permalink
Added twisted based proxy server
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Sep 20, 2009
1 parent d33b909 commit 27a9907
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
30 changes: 26 additions & 4 deletions hurricane/django/management/commands/runcomet.py
@@ -1,11 +1,33 @@
import os
from subprocess import Popen
import sys

from twisted.internet import reactor
from twisted.web import proxy, server

from django.core.management.base import BaseCommand
from django.conf import settings

from hurricane.runner import main


class Command(BaseCommand):
help = "Starts a lightweight Comet server for development."
help = ("Starts a lightweight Comet server, and django development server "
"for development.")

def handle(self, *args, **options):
main(settings)
Popen([
sys.executable,
sys.argv[0],
'runserver',
'--settings=%s' % settings.SETTINGS_MODULE
])
Popen([
sys.executable,
os.path.join(os.path.dirname(__file__), '..', 'runner.py'),
'--settings=%' % settings.SETTINGS_MODULE
])

main_site = proxy.ReverseProxyResource('localhost', 8000, '')
main_site.putChild('comet/',
proxy.ReverseProxyResource('localhost', 8001, 'comet/'))
reactor.listenTCP(8080, server.Site(main_site))
reactor.run()
2 changes: 1 addition & 1 deletion hurricane/handlers/comet/handler.py
Expand Up @@ -166,4 +166,4 @@ def respond_to_request(self, request):
request.write(response.as_bytes())
except IOError:
return
request.finish()
request.finish()
3 changes: 2 additions & 1 deletion optional-dependencies.txt
@@ -1,4 +1,5 @@
simplejson
http://stomppy.googlecode.com/files/stomp.py-2.0.2.tar.gz
-e git://github.com/facebook/tornado.git#egg=tornado
-e git://github.com/ericflo/twitstream.git#egg=twitstream
-e git://github.com/ericflo/twitstream.git#egg=twitstream
Twisted==8.2.0

0 comments on commit 27a9907

Please sign in to comment.