def main(): settings, subdirectory = get_config(config_file) logger.info('Initializing TabPy...') tornado.ioloop.IOLoop.instance().run_sync(lambda: init_ps_server(settings)) logger.info('Done initializing TabPy.') executor = concurrent.futures.ThreadPoolExecutor( max_workers=multiprocessing.cpu_count()) # initialize Tornado application application = tornado.web.Application( [ # skip MainHandler to use StaticFileHandler .* page requests and # default to index.html # (r"/", MainHandler), (subdirectory + r'/query/([^/]+)', QueryPlaneHandler), (subdirectory + r'/status', StatusHandler), (subdirectory + r'/info', ServiceInfoHandler), (subdirectory + r'/endpoints', EndpointsHandler), (subdirectory + r'/endpoints/([^/]+)?', EndpointHandler), (subdirectory + r'/evaluate', EvaluationPlaneHandler, dict(executor=executor)), (subdirectory + r'/configurations/endpoint_upload_destination', UploadDestinationHandler), (subdirectory + r'/(.*)', tornado.web.StaticFileHandler, dict(path=settings['static_path'], default_filename="index.html")), ], debug=False, **settings) settings = application.settings init_model_evaluator(settings) if settings['transfer_protocol'] == 'http': application.listen(settings['port'], address=settings['bind_ip']) elif settings['transfer_protocol'] == 'https': application.listen(settings['port'], address=settings['bind_ip'], ssl_options={ 'certfile': settings['certificate_file'], 'keyfile': settings['key_file'] }) else: raise RuntimeError('Unsupported transfer protocol.') logger.info('Web service listening on {} port {}'.format( settings['bind_ip'], str(settings['port']))) tornado.ioloop.IOLoop.instance().start()
def main(): model = "python " + os.path.dirname( os.path.realpath(__file__)) + '/prod_fraud_model.py' p1 = subprocess.Popen(model, shell=True, stdout=subprocess.PIPE) settings, subdirectory = get_config() print('Initializing TabPy...') tornado.ioloop.IOLoop.instance().run_sync(lambda: init_ps_server(settings)) print('Done initializing TabPy.') executor = concurrent.futures.ThreadPoolExecutor( max_workers=multiprocessing.cpu_count()) # initialize Tornado application application = tornado.web.Application( [ # skip MainHandler to use StaticFileHandler .* page requests and # default to index.html # (r"/", MainHandler), (subdirectory + r'/query/([^/]+)', QueryPlaneHandler), (subdirectory + r'/status', StatusHandler), (subdirectory + r'/info', ServiceInfoHandler), (subdirectory + r'/endpoints', EndpointsHandler), (subdirectory + r'/endpoints/([^/]+)?', EndpointHandler), (subdirectory + r'/evaluate', EvaluationPlaneHandler, dict(executor=executor)), (subdirectory + r'/configurations/endpoint_upload_destination', UploadDestinationHandler), (subdirectory + r'/(.*)', tornado.web.StaticFileHandler, dict(path=settings['static_path'], default_filename="index.html")), ], debug=False, **settings) settings = application.settings init_model_evaluator(settings) application.listen(settings['port'], address=settings['bind_ip']) print('Web service listening on {} port {}'.format(settings['bind_ip'], str(settings['port']))) tornado.ioloop.IOLoop.instance().start()
def _create_tornado_web_app(self): logger.info('Initializing TabPy...') tornado.ioloop.IOLoop.instance().run_sync( lambda: init_ps_server(self.settings, self.tabpy_state)) logger.info('Done initializing TabPy.') executor = concurrent.futures.ThreadPoolExecutor( max_workers=multiprocessing.cpu_count()) # initialize Tornado application application = tornado.web.Application( [ # skip MainHandler to use StaticFileHandler .* page requests and # default to index.html # (r"/", MainHandler), (self.subdirectory + r'/query/([^/]+)', QueryPlaneHandler, dict(app=self)), (self.subdirectory + r'/status', StatusHandler, dict(app=self)), (self.subdirectory + r'/info', ServiceInfoHandler, dict(app=self)), (self.subdirectory + r'/endpoints', EndpointsHandler, dict(app=self)), (self.subdirectory + r'/endpoints/([^/]+)?', EndpointHandler, dict(app=self)), (self.subdirectory + r'/evaluate', EvaluationPlaneHandler, dict(executor=executor, app=self)), (self.subdirectory + r'/configurations/endpoint_upload_destination', UploadDestinationHandler, dict(app=self)), (self.subdirectory + r'/(.*)', tornado.web.StaticFileHandler, dict(path=self.settings[SettingsParameters.StaticPath], default_filename="index.html")), ], debug=False, **self.settings) return application