-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (22 loc) · 846 Bytes
/
main.py
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
import argparse
import asyncio
from redis import RedisServer
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=6379)
parser.add_argument("--replicaof", type=str, default=None)
parser.add_argument("--dir", type=str, default=None)
parser.add_argument("--dbfilename", type=str, default=None)
return parser.parse_args()
def main() -> None:
args = parse_args()
address = "localhost", args.port
if args.replicaof is not None:
master_host, master_port = args.replicaof.split()
master_address = master_host, int(master_port)
server = RedisServer(address, master_address)
else:
server = RedisServer(address, dir=args.dir, dbfilename=args.dbfilename)
asyncio.run(server.start())
if __name__ == "__main__":
main()