-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_service_main.py
48 lines (39 loc) · 1.09 KB
/
eth_service_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
import argparse
from services.eth_node_mock.core import App
def get_input_args():
default_api_url = '127.0.0.1:18545'
default_ws_url = '127.0.0.1:8545'
parser = argparse.ArgumentParser()
parser.add_argument(
'-u',
'--url',
help=f'Defines Node server RPC address, default [{default_api_url}]',
type=str,
default=default_api_url,
)
parser.add_argument(
'-w',
'--ws',
help=f'Defines Node server WebSocket address, default [{default_ws_url}]',
type=str,
default=default_ws_url,
)
args = parser.parse_args()
return {
'url': args.url or default_api_url,
'ws': args.ws or default_ws_url,
}
def run(input_args):
app = App()
loop = asyncio.get_event_loop()
try:
asyncio.ensure_future(app.start(input_args, loop))
print('node started')
loop.run_forever()
except (KeyboardInterrupt,):
print('lets exit...')
loop.run_until_complete(app.stop())
loop.close()
if __name__ == '__main__':
run(get_input_args())