Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cli.py
# Copyright (C) 2015-2019 The Software Heritage developers | # Copyright (C) 2015-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
import os | import os | ||||
import warnings | |||||
import click | import click | ||||
from swh.core import config | from swh.core import config | ||||
from swh.core.cli import CONTEXT_SETTINGS | from swh.core.cli import CONTEXT_SETTINGS | ||||
from swh.storage.api.server import load_and_check_config, app | from swh.storage.api.server import load_and_check_config, app | ||||
Show All 19 Lines | else: | ||||
conf = {} | conf = {} | ||||
ctx.ensure_object(dict) | ctx.ensure_object(dict) | ||||
ctx.obj["config"] = conf | ctx.obj["config"] = conf | ||||
@storage.command(name="rpc-serve") | @storage.command(name="rpc-serve") | ||||
@click.argument("config-path", required=True) | @click.argument("config-path", default=None, required=False) | ||||
@click.option( | @click.option( | ||||
"--host", | "--host", | ||||
default="0.0.0.0", | default="0.0.0.0", | ||||
metavar="IP", | metavar="IP", | ||||
show_default=True, | show_default=True, | ||||
help="Host ip address to bind the server on", | help="Host ip address to bind the server on", | ||||
) | ) | ||||
@click.option( | @click.option( | ||||
Show All 12 Lines | |||||
@click.pass_context | @click.pass_context | ||||
def serve(ctx, config_path, host, port, debug): | def serve(ctx, config_path, host, port, debug): | ||||
"""Software Heritage Storage RPC server. | """Software Heritage Storage RPC server. | ||||
Do NOT use this in a production environment. | Do NOT use this in a production environment. | ||||
""" | """ | ||||
if "log_level" in ctx.obj: | if "log_level" in ctx.obj: | ||||
logging.getLogger("werkzeug").setLevel(ctx.obj["log_level"]) | logging.getLogger("werkzeug").setLevel(ctx.obj["log_level"]) | ||||
if config_path: | |||||
# for bw compat | |||||
warnings.warn( | |||||
"The `config_path` argument of the `swh storage rpc-server` is now " | |||||
"deprecated. Please use the --config option of `swh storage` instead.", | |||||
DeprecationWarning, | |||||
) | |||||
api_cfg = load_and_check_config(config_path, type="any") | api_cfg = load_and_check_config(config_path, type="any") | ||||
app.config.update(api_cfg) | app.config.update(api_cfg) | ||||
else: | |||||
app.config.update(ctx.obj["config"]) | |||||
app.run(host, port=int(port), debug=bool(debug)) | app.run(host, port=int(port), debug=bool(debug)) | ||||
@storage.command() | @storage.command() | ||||
@click.argument("object_type") | @click.argument("object_type") | ||||
@click.option("--start-object", default=None) | @click.option("--start-object", default=None) | ||||
@click.option("--end-object", default=None) | @click.option("--end-object", default=None) | ||||
@click.option("--dry-run", is_flag=True, default=False) | @click.option("--dry-run", is_flag=True, default=False) | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |