Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/api/server.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def run_from_webserver(environ, start_response, | ||||
cfg = config.load_named_config(config_path, DEFAULT_CONFIG) | cfg = config.load_named_config(config_path, DEFAULT_CONFIG) | ||||
app.config.update(cfg) | app.config.update(cfg) | ||||
handler = logging.StreamHandler() | handler = logging.StreamHandler() | ||||
app.logger.addHandler(handler) | app.logger.addHandler(handler) | ||||
return app(environ, start_response) | return app(environ, start_response) | ||||
@click.command() | @click.command() | ||||
@click.argument('config-path', required=1) | |||||
@click.option('--host', default='0.0.0.0', help="Host to run the server") | @click.option('--host', default='0.0.0.0', help="Host to run the server") | ||||
@click.option('--port', default=5007, type=click.INT, | @click.option('--port', default=5007, type=click.INT, | ||||
help="Binding port of the server") | help="Binding port of the server") | ||||
@click.option('--debug/--nodebug', default=True, | @click.option('--debug/--nodebug', default=True, | ||||
help="Indicates if the server should run in debug mode") | help="Indicates if the server should run in debug mode") | ||||
def launch(host, port, debug): | def launch(config_path, host, port, debug): | ||||
cfg = config.load_named_config(DEFAULT_CONFIG_PATH, DEFAULT_CONFIG) | app.config.update(config.read(config_path, DEFAULT_CONFIG)) | ||||
app.config.update(cfg) | |||||
app.run(host, port=int(port), debug=bool(debug)) | app.run(host, port=int(port), debug=bool(debug)) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
launch() | launch() |