def start(self): # get properties flaskHost = Configuration.getFlaskHost() if self.argument_port is not None: if type(self.argument_port) == int: flaskPort = self.argument_port else: flaskPort = Configuration.getFlaskPort() else: flaskPort = Configuration.getFlaskPort() flaskDebug = Configuration.getFlaskDebug() # logging if Configuration.getLogging(): logfile = Configuration.getLogfile() pathToLog = logfile.rsplit('/', 1)[0] if not os.path.exists(pathToLog): os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) self.app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server self.app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): ssl_options = { "certfile": os.path.join(_runPath, "../", Configuration.getSSLCert()), "keyfile": os.path.join(_runPath, "../", Configuration.getSSLKey()) } else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options) self.http_server.bind(flaskPort, address=flaskHost) # self.http_server.start(0) # Forks multiple sub-processes self.http_server.start( ) # Don't fork, since MongoDB connection is made earlier and not Fork-safe. IOLoop.instance().start()
def start(self): # get properties flaskHost = Configuration.getFlaskHost() flaskPort = Configuration.getFlaskPort() flaskDebug = Configuration.getFlaskDebug() # logging # if Configuration.getLogging(): # logfile = Configuration.getLogfile() # pathToLog = logfile.rsplit("/", 1)[0] # if not os.path.exists(pathToLog): # os.makedirs(pathToLog) # maxLogSize = Configuration.getMaxLogSize() # backlog = Configuration.getBacklog() # file_handler = RotatingFileHandler( # logfile, maxBytes=maxLogSize, backupCount=backlog # ) # file_handler.setLevel(logging.ERROR) # formatter = logging.Formatter( # "%(asctime)s - %(name)s - %(levelname)s - %(message)s" # ) # file_handler.setFormatter(formatter) # self.app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server self.app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): ssl_options = { "certfile": os.path.join(_runPath, "../../../", Configuration.getSSLCert()), "keyfile": os.path.join(_runPath, "../../../", Configuration.getSSLKey()), } else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options) self.http_server.bind(flaskPort, address=flaskHost) self.http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
def start(self): # get properties context = SSL.Context(SSL.SSLv23_METHOD) context.use_certificate_file('cvesite.crt') context.use_privatekey_file('cvesite.key') flaskHost = '0.0.0.0' flaskPort = 443 flaskDebug = Configuration.getFlaskDebug() # logging if Configuration.getLogging(): logfile = Configuration.getLogfile() pathToLog = logfile.rsplit('/', 1)[0] if not os.path.exists(pathToLog): os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) self.app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server context = ('cvesite.crt', 'cvesite.key') self.app.run(host=flaskHost, port=flaskPort, debug=False,ssl_context=context,threaded=True) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): ssl_options = {"certfile": os.path.join(_runPath, "../", Configuration.getSSLCert()), "keyfile": os.path.join(_runPath, "../", Configuration.getSSLKey())} else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=context) self.http_server.bind(flaskPort, address=flaskHost) self.http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
def start(self): # get properties flaskHost = Configuration.getFlaskHost() flaskPort = Configuration.getFlaskPort() flaskDebug = Configuration.getFlaskDebug() # logging if Configuration.getLogging(): logfile = Configuration.getLogfile() pathToLog = logfile.rsplit('/', 1)[0] if not os.path.exists(pathToLog): os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) self.app.logger.addHandler(file_handler) # Placing routes - Doing this later allows us to define multiple API instances, without flask problems for route in web.Routes.get_routes(self): self.addRoute(route) if flaskDebug: # start debug flask server self.app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): ssl_options = {"certfile": os.path.join(_runPath, "../", Configuration.getSSLCert()), "keyfile": os.path.join(_runPath, "../", Configuration.getSSLKey())} else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options) self.http_server.bind(flaskPort, address=flaskHost) self.http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
def start(self): # logging if conf.getLogging(): logfile = conf.getLogfile() pathToLog = logfile.rsplit('/', 1)[0] if not os.path.exists(pathToLog): os.makedirs(pathToLog) file_handler = RotatingFileHandler(logfile, maxBytes=conf.getMaxLogSize(), backupCount=conf.getBacklog()) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) self.app.logger.addHandler(file_handler) #for route in web.Routes.get_routes(self): self.addRoute(route) if conf.getDebug(): # start debug flask server self.app.run(host=conf.getHost(), port=conf.getPort(), debug=True) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if conf.useSSL(): ssl_options = { "certfile": os.path.join(_runPath, "../", conf.getSSLCert()), "keyfile": os.path.join(_runPath, "../", conf.getSSLKey()) } else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options) self.http_server.bind(conf.getPort(), address=conf.getHost()) self.http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
def start(self): # get properties flaskHost = Configuration.getFlaskHost() flaskPort = Configuration.getFlaskPort() flaskDebug = Configuration.getFlaskDebug() # logging if Configuration.getLogging(): logfile = Configuration.getLogfile() pathToLog = logfile.rsplit('/', 1)[0] if not os.path.exists(pathToLog): os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) self.app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server self.app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): ssl_options = {"certfile": os.path.join(_runPath, "../", Configuration.getSSLCert()), "keyfile": os.path.join(_runPath, "../", Configuration.getSSLKey())} else: ssl_options = None signal.signal(signal.SIGTERM, self.sig_handler) signal.signal(signal.SIGINT, self.sig_handler) self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options) self.http_server.bind(flaskPort, address=flaskHost) self.http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): cert = os.path.join(_runPath, "../", Configuration.getSSLCert()) key = os.path.join(_runPath, "../", Configuration.getSSLKey()) ssl_options = {"certfile": cert, "keyfile": key} else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): cert = os.path.join(_runPath, "../", Configuration.getSSLCert()) key = os.path.join(_runPath, "../", Configuration.getSSLKey()) ssl_options = {"certfile": cert, "keyfile": key} else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
stop_loop() if __name__ == '__main__': flaskHost = conf.getFlaskHost() flaskPort = conf.getFlaskPort() flaskDebug = conf.getFlaskDebug() if flaskDebug: #start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if conf.useSSL(): ssl_options = { "certfile": conf.getSSLCert(), "keyfile": conf.getSSLKey() } else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) plugManager.loadPlugins() if flaskDebug: # start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): cert = Configuration.getSSLCert() key = Configuration.getSSLKey() ssl_options = {"certfile": cert, "keyfile": key} else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
os.makedirs(pathToLog) maxLogSize = Configuration.getMaxLogSize() backlog = Configuration.getBacklog() file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if flaskDebug: # start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if Configuration.useSSL(): cert = Configuration.getSSLCert() key = Configuration.getSSLKey() ssl_options = {"certfile": cert, "keyfile": key} else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()
else: io_loop.stop() print("Shutdown") stop_loop() if __name__ == "__main__": flaskHost = conf.getFlaskHost() flaskPort = conf.getFlaskPort() flaskDebug = conf.getFlaskDebug() if flaskDebug: # start debug flask server app.run(host=flaskHost, port=flaskPort, debug=flaskDebug) else: # start asynchronous server using tornado wrapper for flask # ssl connection print("Server starting...") if conf.useSSL(): ssl_options = {"certfile": conf.getSSLCert(), "keyfile": conf.getSSLKey()} else: ssl_options = None signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) global http_server http_server = HTTPServer(WSGIContainer(app), ssl_options=ssl_options) http_server.bind(flaskPort, address=flaskHost) http_server.start(0) # Forks multiple sub-processes IOLoop.instance().start()