main.py 1.21 KB
Newer Older
maming's avatar
maming committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Copyright (c) 2025, NVIDIA CORPORATION.
# SPDX-License-Identifier: BSD-3-Clause
from pathlib import Path

import click

from .server import S3EmulatorServer


@click.command()
@click.option(
    "--host",
    default="0.0.0.0",
    help="Host to bind the server to",
)
@click.option(
    "--port",
    default=9000,
    type=int,
    help="Port to bind the server to",
)
@click.option(
    "--root-dir",
    type=click.Path(path_type=Path),
    help="Directory to persist S3 data",
)
@click.option(
    "--access-key",
    default="test",
    help="Access key for authentication",
)
@click.option(
    "--secret-key",
    default="test",
    help="Secret key for authentication",
)
@click.option(
    "--region",
    default="us-east-1",
    help="Region for authentication",
)
def main(
    host: str, port: int, root_dir: Path | None, access_key: str, secret_key: str, region: str
) -> None:
    """Start an S3 emulator server."""
    server = S3EmulatorServer(
        host=host,
        port=port,
        credentials={access_key: secret_key},
        root_dir=root_dir,
        region=region,
    )
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.shutdown()


if __name__ == "__main__":
    main()