Ejemplo n.º 1
0
def startserver(force=False):
    """ start the rest server. """
    if not enable: logging.debug("rest server is disabled") ; return
    global server 
    if server and not force: logging.debug("REST server is already running. ") ; return server
    try:
        server = RestServer((cfg.get('host'), cfg.get('port')), RestRequestHandler)
        if server:
            server.start()
            logging.warn('restserver - running at %s:%s' % (cfg.get('host'), cfg.get('port')))
            for mount in cfg.get('disable'): server.disable(mount)
        else: logging.error('restserver - failed to start server at %s:%s' % (cfg.get('host'), cfg.get('port')))
    except socket.error, ex: logging.warn('restserver - start - socket error: %s' % str(ex))
    except Exception, ex: handle_exception()
    return server
Ejemplo n.º 2
0
def startserver():
    global server 
    try:
        logging.warn('restbeam - starting server at %s:%s' % (cfg.get('host'), cfg.get('port')))
        time.sleep(2)
        server = RestServer((cfg.get('host'), cfg.get('port')), RestRequestHandler)

        if server:
            server.start()
            logging.warn('restbeam - running at %s' % url)
            server.addhandler('/', 'GET', playlist_GET)
            server.addhandler('/login/*', 'GET', login_GET)
            server.addhandler('/logout/', 'GET', logout_GET)
            server.addhandler('/top/', 'GET', topstats_GET)
            server.addhandler('/top', 'GET', topstats_GET)
            for mount in cfg.get('disable'): server.disable(mount)
        else: logging.error('restbeam - failed to start server at %s:%s' % (cfg.get('host'), cfg.get('port')))

    except socket.error, ex: logging.warn('restbeam - server - %s' % str(ex))
    except Exception, ex: handle_exception()