-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcli.py
executable file
·136 lines (108 loc) · 3.53 KB
/
cli.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python3
import click
from bexi.wsgi.app import (
get_manage_service_app,
get_sign_service_app,
get_blockchain_monitor_service_app
)
from bexi import Config
from bexi.connection import requires_blockchain
from bexi.blockchain_monitor import BlockchainMonitor
import logging
import threading
config = Config.get("wsgi")
@click.group()
def main():
pass
@main.command()
@click.option("--host")
@click.option("--port")
def wsgi(host, port):
host = host or config["host"]
port = port or config["port"]
app = get_manage_service_app()
app = get_sign_service_app(app)
app.logger.info("Starting " + config["name"] + " with manage and sign service ...")
app.run(host=host, port=port, debug=True)
@main.command()
@click.option("--host")
@click.option("--port")
def sign_service(host, port):
host = host or config["host"]
port = port or config["port"]
app = get_sign_service_app()
app.logger.info("Starting " + config["name"] + " sign service ...")
app.run(host=host, port=port)
@main.command()
@click.option("--host")
@click.option("--port")
def manage_service(host, port):
host = host or config["host"]
port = port or config["port"]
app = get_manage_service_app()
app.logger.info("Starting " + config["name"] + " manage service ...")
app.run(host=host, port=port)
@main.command()
@click.option("--host")
@click.option("--port")
def blockchain_monitor_service(host, port):
host = host or config["host"]
port = port or config["port"]
app = get_blockchain_monitor_service_app()
logging.getLogger(__name__).info("Starting BitShares blockchain monitor as coroutines ...")
thr = threading.Thread(target=start_block_monitor, daemon=True)
thr.start() # run in background
app.logger.info("Starting " + config["name"] + " blockchain monitor service ...")
app.run(host=host, port=port)
@main.command()
def only_blockchain_monitor():
Config.load(["config_bitshares_connection.yaml",
"config_bitshares_memo_keys.yaml",
"config_bitshares.yaml",
"config_operation_storage.yaml"])
logging.getLogger(__name__).info("Starting BitShares blockchain monitor ...")
start_block_monitor()
@main.command()
@click.option("--host")
@click.option("--port")
def only_blockchain_monitor_service(host, port):
host = host or config["host"]
port = port or config["port"]
app = get_blockchain_monitor_service_app()
app.logger.info("Starting " + config["name"] + " blockchain monitor service ...")
app.run(host=host, port=port)
@requires_blockchain
def start_block_monitor():
monitor = BlockchainMonitor()
monitor.listen()
# @main.command()
# def yaml_to_json():
# os.environ["SettingsUrl"] = None
# os.environ["PrivateKey"] = None
#
# Config.reset()
#
# Config.load("config_common.yaml")
# get_sign_service_app()
# Config.dump_current("config_sign_service.json")
#
# Config.reset()
#
# Config.load("config_common.yaml")
# get_manage_service_app()
# Config.dump_current("config_manage_service.json")
#
# Config.reset()
#
# Config.load("config_common.yaml")
# load_blockchain_monitor_config()
# Config.dump_current("config_blockchain_monitor.json")
#
# Config.reset()
#
# Config.load("config_common.yaml")
# get_blockchain_monitor_service_app()
# Config.dump_current("config_blockchain_monitor_service.json")
#
# print("JSon configuration files for sign_service, manage_service and blockchain_monitor written to dump folder")
main()