forked from enricozanardo/BeezX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (26 loc) · 1.06 KB
/
main.py
File metadata and controls
38 lines (26 loc) · 1.06 KB
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
from loguru import logger
from beez.node.beez_node import BeezNode
import threading
import pathlib
import sys
import os
import time
def start_p2p_thread(node):
node.start_p2p()
def start_api_thread(node, port):
node.start_api(port)
if __name__ == "__main__":
key_path = os.getenv("BEEZ_NODE_KEY_PATH", None)
if not key_path:
logger.info("Can't start node, no path to private key set in env variable BEEZ_NODE_KEY_PATH")
raise Exception("no key path given")
currentPath = pathlib.Path().resolve()
# genesis_private_key_path = f"{currentPath}/beez/keys/genesisPrivateKey.pem"
# node = BeezNode(key="/Users/lukashubl/tmp/BeezX/beez/keys/genesisPrivateKey.pem")
node = BeezNode(key=key_path)
p2p_port = sys.argv[1] if len(sys.argv) > 1 else 5444
api_port = sys.argv[2] if len(sys.argv) > 2 else 5445
p2p_thread = threading.Thread(target=start_p2p_thread, args=(node, ))
p2p_thread.start()
api_thread = threading.Thread(target=start_api_thread, args=(node, int(api_port), ))
api_thread.start()