Changeset 548 for trunk/daemon/orbited/start.py

Show
Ignore:
Timestamp:
10/10/08 08:26:54 (3 months ago)
Author:
heyadayo
Message:

Auto detect Orbited.settings.hostname and Orbited.settings.port; Required morbid for install; Allow Orbited to use morbid to act as an embedded stomp broker.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/daemon/orbited/start.py

    r545 r548  
    2525            reactor.listenWith(port_class, factory=factory_class(), resource=root, childName=child_path) 
    2626            logger.info('%s protocol active' % config_key) 
    27  
     27     
    2828def _setup_static(root, config): 
    2929    from twisted.web import static 
     
    4646    global logger; logger = logging.get_logger('orbited.start') 
    4747 
     48 
    4849    # NB: we need to install the reactor before using twisted. 
    4950    reactor_name = config.map['[global]'].get('reactor') 
     
    6162    static_files = static.File(os.path.join(os.path.dirname(__file__), 'static')) 
    6263    root.putChild('static', static_files) 
     64    #static_files.putChild('orbited.swf', static.File(os.path.join(os.path.dirname(__file__), 'flash', 'orbited.swf'))) 
    6365    site = server.Site(root) 
    6466 
     
    7072def start_listening(site, config, logger): 
    7173    from twisted.internet import reactor 
     74    # allow stomp:// URIs to be parsed by urlparse  
     75    urlparse.uses_netloc.append('stomp') 
     76 
    7277    for addr in config['[listen]']: 
    7378        url = urlparse.urlparse(addr) 
    7479        hostname = url.hostname or '' 
    75         if url.scheme == 'http': 
     80        if url.scheme == 'stomp': 
     81            logger.info('Listening stomp@%s' % url.port) 
     82            from morbid import StompFactory 
     83            reactor.listenTCP(url.port, StompFactory(), interface=hostname)      
     84        elif url.scheme == 'http': 
    7685            logger.info('Listening http@%s' % url.port) 
    7786            reactor.listenTCP(url.port, site, interface=hostname)