-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKoloocheh.py
32 lines (27 loc) · 833 Bytes
/
Koloocheh.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
import sys, logging
from peer_interface import PeerInterface
from koloocheh_pb2 import Address
from master import Master
from const import Const
def main():
logging.basicConfig(level=logging.INFO)
if len(sys.argv) > 1:
if sys.argv[1] == "master":
master = Master(
Address(
ip=Const.MASTER_ADDRESS.ip,
port=Const.MASTER_ADDRESS.port
)
)
master.run()
elif sys.argv[1] == "peer":
ip, port = sys.argv[2], int(sys.argv[3])
address = Address(
ip=ip,
port=port
)
peer_interface = PeerInterface(address)
peer_interface.advertise_to_master()
peer_interface.run()
if __name__ == "__main__":
main()