in analysis/webservice/webapp.py [0:0]
def main():
start = datetime.now()
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt="%Y-%m-%dT%H:%M:%S", stream=sys.stdout
)
log = logging.getLogger(__name__)
for line in banner:
log.info(line)
web_config = configparser.RawConfigParser()
web_config.read_file(open(os.path.join(os.path.dirname(__file__), "config", "web.ini")))
algorithm_config = configparser.RawConfigParser()
algorithm_config.read_file(open(os.path.join(os.path.dirname(__file__), "config", "algorithms.ini")))
define("debug", default=False, help="run in debug mode")
define("port", default=web_config.get("global", "server.socket_port"), help="run on the given port", type=int)
define("address", default=web_config.get("global", "server.socket_host"), help="Bind to the given address")
define('solr_time_out', default=60,
help='time out for solr requests in seconds, default (60) is ok for most deployments'
' when solr performances are not good this might need to be increased')
define('solr_host', help='solr host and port')
define('cassandra_host', help='cassandra host')
define('cassandra_username', help='cassandra username')
define('cassandra_password', help='cassandra password')
define('collections_path', default=None, help='collection config path')
parse_command_line()
algorithm_config = inject_args_in_config(options, algorithm_config)
remote_collections = None
router_rules = []
if options.collections_path:
# build retirect app
remote_collection_matcher = RemoteCollectionMatcher(options.collections_path)
remote_collections = remote_collection_matcher.get_remote_collections()
remote_sdap_app = RedirectAppBuilder(remote_collection_matcher).build(
host=options.address,
debug=options.debug)
router_rules.append(Rule(remote_collection_matcher, remote_sdap_app))
# build nexus app
nexus_app_builder = NexusAppBuilder().set_modules(
web_config.get("modules", "module_dirs").split(","),
algorithm_config,
remote_collections=remote_collections
)
if web_config.get("static", "static_enabled") == "true":
nexus_app_builder.enable_static(
web_config.get("static", "static_dir")
)
else:
log.info("Static resources disabled")
local_sdap_app = nexus_app_builder.build(host=options.address, debug=options.debug)
router_rules.append(Rule(AnyMatches(), local_sdap_app))
router = RuleRouter(router_rules)
log.info("Initializing on host address '%s'" % options.address)
log.info("Initializing on port '%s'" % options.port)
log.info("Starting web server in debug mode: %s" % options.debug)
server = tornado.web.HTTPServer(router)
server.listen(options.port)
log.info('Waiting for dataset backends to come up...')
with NexusTileService.DS_LOCK:
if not NexusTileService.is_update_thread_alive():
log.critical('A fatal error occurred when loading the datasets')
exit(-1)
log.info(f"SDAP started in {datetime.now() - start}. Starting HTTP listener...")
tornado.ioloop.IOLoop.current().start()