Skip to content
Browse files

updating to work with Ginkgo

  • Loading branch information...
1 parent 93e6d5e commit 288fc652d49e1dcec2cba2ee5e01f1fc74c39bac @progrium committed Apr 25, 2012
Showing with 21 additions and 38 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 Procfile
  3. +2 −3 config/client.conf.py
  4. +1 −3 config/default.conf.py
  5. +1 −3 config/heroku.conf.py
  6. +4 −5 localtunnel/client.py
  7. +7 −6 localtunnel/server.py
  8. +2 −5 requirements.txt
  9. +0 −8 scripts/gservice
  10. +0 −3 scripts/run.sh
  11. +1 −1 setup.py
View
2 .gitignore
@@ -1,4 +1,6 @@
bin
+*.pyc
+**/*.pyc
build
dist
*.egg-info
View
2 Procfile
@@ -1 +1 @@
-web: ./scripts/run.sh ./config/heroku.conf.py
+web: bin/python setup.py develop && bin/python -c "__requires__ = 'ginkgo'; import sys; from pkg_resources import load_entry_point; sys.exit(load_entry_point('ginkgo', 'console_scripts', 'ginkgo')())" ./config/heroku.conf.py
View
5 config/client.conf.py
@@ -2,6 +2,5 @@
port = 9999
hostname = 'localhost'
-def service():
- from localtunnel.server import TunnelClient
- return TunnelClient()
+service = 'localtunnel.server.TunnelClient'
+
View
4 config/default.conf.py
@@ -1,6 +1,4 @@
port = 9999
hostname = 'localtunnel.local'
-def service():
- from localtunnel.server import TunnelBroker
- return TunnelBroker()
+service = 'localtunnel.server.TunnelBroker'
View
4 config/heroku.conf.py
@@ -3,6 +3,4 @@
port = int(os.environ.get("PORT", 5000))
hostname = 'v2.localtunnel.com'
-def service():
- from localtunnel.server import TunnelBroker
- return TunnelBroker()
+service = 'localtunnel.server.TunnelBroker'
View
9 localtunnel/client.py
@@ -5,8 +5,7 @@
from gevent.socket import create_connection
from gevent.coros import Semaphore
-from gservice.config import Option
-from gservice.core import Service
+from ginkgo import Service
from ws4py.client.geventclient import WebSocketClient
@@ -41,7 +40,7 @@ def __init__(self, local_port, name, broker_address):
def do_start(self):
self.ws.connect()
- gevent.spawn(self.listen)
+ self.spawn(self.listen)
#gevent.spawn(self.visual_heartbeat)
def visual_heartbeat(self):
@@ -70,7 +69,7 @@ def listen(self):
def local_open(self, conn_id):
socket = create_connection(('0.0.0.0', self.local_port))
self.connections[conn_id] = socket
- gevent.spawn(self.local_recv, conn_id)
+ self.spawn(self.local_recv, conn_id)
def local_close(self, conn_id):
socket = self.connections.pop(conn_id)
@@ -101,4 +100,4 @@ def tunnel_send(self, conn_id, data=None, open=None):
with self._send_lock:
self.ws.send(msg, binary=True)
else:
- return
+ return
View
13 localtunnel/server.py
@@ -7,8 +7,9 @@
from gevent.queue import Queue
from gevent.pool import Group
-from gservice.config import Option
-from gservice.core import Service
+from ginkgo import Setting
+from ginkgo import Service
+from ginkgo.async.gevent import ServerWrapper
from ws4py.server.geventserver import UpgradableWSGIHandler
from ws4py.server.wsgi.middleware import WebSocketUpgradeMiddleware
@@ -30,12 +31,12 @@ def discard(self, greenlet):
class TunnelBroker(Service):
"""Top-level service that manages tunnels and runs the frontend"""
- port = Option('port', default=80)
- address = Option('address', default='0.0.0.0')
+ port = Setting('port', default=80)
+ address = Setting('address', default='0.0.0.0')
def __init__(self):
self.frontend = BrokerFrontend(self)
- self.add_service(self.frontend)
+ self.add_service(ServerWrapper(self.frontend))
self.tunnels = {}
@@ -63,7 +64,7 @@ def lookup_tunnel(self, name):
class BrokerFrontend(gevent.pywsgi.WSGIServer):
"""Server that will manage a tunnel or proxy traffic through a tunnel"""
- hostname = Option('hostname', default="localtunnel.com")
+ hostname = Setting('hostname', default="localtunnel.com")
def __init__(self, broker):
gevent.pywsgi.WSGIServer.__init__(self, (broker.address, broker.port))
View
7 requirements.txt
@@ -1,9 +1,6 @@
-git+git://github.com/progrium/gservice.git#egg=gservice
+git+git://github.com/progrium/ginkgo.git#egg=Ginkgo
git+git://github.com/progrium/WebSocket-for-Python.git#egg=ws4py-dev
-gevent==0.13.3
+gevent==0.13.6
greenlet==0.3.1
-lockfile==0.9.1
nose==1.1.2
-python-daemon==1.6
-setproctitle==1.1.2
wsgiref==0.1.2
View
8 scripts/gservice
@@ -1,8 +0,0 @@
-# EASY-INSTALL-ENTRY-SCRIPT: 'gservice','console_scripts','gservice'
-__requires__ = 'gservice'
-import sys
-from pkg_resources import load_entry_point
-
-sys.exit(
- load_entry_point('gservice', 'console_scripts', 'gservice')()
-)
View
3 scripts/run.sh
@@ -1,3 +0,0 @@
-#!/bin/bash
-bin/python setup.py develop
-bin/python ./scripts/gservice -C $1
View
2 setup.py
@@ -9,7 +9,7 @@
author_email='jeff.lindsay@twilio.com',
description='',
packages=find_packages(),
- install_requires=['gservice', 'ws4py'],
+ install_requires=['Ginkgo', 'ws4py'],
data_files=[],
entry_points={
'console_scripts': [

0 comments on commit 288fc65

Please sign in to comment.
Something went wrong with that request. Please try again.