-
Notifications
You must be signed in to change notification settings - Fork 4
/
local.planofile
59 lines (44 loc) · 2.13 KB
/
local.planofile
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
@command
def build(app):
for dir in ("frontend", "order-processor", "market-data"):
copy("python/data.py", join(dir, "python/data.py"))
@command
def clean(app):
for dir in find(".", "__pycache__"):
remove(dir)
@command
def run_(app):
build(app)
procs = list()
remove("/tmp/kafka-logs")
remove("/tmp/zookeeper")
try:
with working_dir(join(get_home_dir(), "kafka")):
procs.append(start("bin/zookeeper-server-start.sh config/zookeeper.properties"))
await_port(2181)
procs.append(start("bin/kafka-server-start.sh config/server.properties"))
await_port(9092)
run("bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic orders --delete", check=False)
run("bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic updates --delete", check=False)
run("bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic orders --create --partitions 3")
run("bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic updates --create --partitions 1")
with working_dir("order-processor"):
procs.append(start("python3 main.py"))
procs.append(start("python3 main.py"))
with working_dir("market-data"):
procs.append(start("python3 main.py"))
with working_dir("frontend"):
procs.append(start("python3 main.py"))
with working_env(HTTP_PORT=8081):
procs.append(start("python3 main.py"))
while True:
sleep(86400)
finally:
for proc in reversed(procs):
kill(proc)
@command
def create_topics(app):
run(f"~/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic orders --delete || :", shell=True)
run(f"~/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic updates --delete || :", shell=True)
run(f"~/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic orders --create --partitions 3", shell=True)
run(f"~/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic updates --create --partitions 1", shell=True)