Esempio n. 1
0
    def setUpClass(cls):
        super(FunctionalTestController, cls).setUpClass()
        
        #from ensconce import server_autoconfig
        
        if not server.configured:
            server.configure()
        
        assert 'db' in config['auth.provider'], "Need to have 'db' in providers list."
        assert not config['server.ssl_certificate'], "SSL isn't supported yet for functional tests."
        
        # This is done so that we get a nicer error message if the port is still in-use.
        # (CherryPy will just silently sys.exit())
        
        # Let's try using cherrypy's method directly.
        #if not check_port(config["server.socket_host"], config["server.socket_port"]):
        #    raise IOError("Port is not free: {0}:{1}".format(config["server.socket_host"], config["server.socket_port"]))
        #
        # Interestingly that fails ..
        
        wait_for_free_port(config["server.socket_host"], config["server.socket_port"], timeout=60) # net.ipv4.tcp_fin_timeout
        
#        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#        sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # http://www.unixguide.net/network/socketfaq/4.5.shtml
#        sock.bind((config["server.socket_host"], config["server.socket_port"]))
#        sock.close()
        
        cherrypy.engine.start()
        cherrypy.engine.wait(cherrypy.engine.states.STARTED)
Esempio n. 2
0
def run_server(argv=None):
    if argv is None:
        argv = sys.argv
        
    parser = optparse.OptionParser(description='Run the ensconce cherrypy server.')
    init_app()
    
    parser.add_option('-d', '--debug',
                      default=config.get('debug', False),
                      action="store_true",
                      help='Run in debug mode?')
    
    (options, args) = parser.parse_args()
    
    config['debug'] = options.debug
    server.configure()
    server.serve_forever()
Esempio n. 3
0
"""
This is a helper module that effectively configures the application at import time.

This exists for cherryd to be able to simply call `import ensconce.server_autoconfig`
and have cherrypy be fully configured (with default config file paths, etc) for serving.
"""
from ensconce import config
from ensconce import server

# Module-level initialization is deliberate here.  This should only ever be imported
# by cherryd.

config.init_app()
server.configure()