-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.py
66 lines (55 loc) · 1.48 KB
/
api.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
import argparse
from time import sleep
from charitybot2.paths import private_api_script_path, console_script_path, overlay_script_path
from charitybot2.start_service import Service, ServiceRunner
from helpers.setup_test_database import setup_test_database
parser = argparse.ArgumentParser(description='CharityBot2 Deployment Tool')
parser.add_argument(
'--debug',
dest='debug',
action='store_true',
default=False,
help='Run CB2 in debug mode')
args = parser.parse_args()
debug = args.debug
if debug:
setup_test_database(donation_count=10)
api_service = Service(
name='Private API',
app=None,
address='127.0.0.1',
port=8001,
debug=debug)
api_runner = ServiceRunner(
service=api_service,
file_path=private_api_script_path)
overlay_service = Service(
name='Overlay',
app=None,
address='127.0.0.1',
port=7000,
debug=debug)
overlay_runner = ServiceRunner(
service=overlay_service,
file_path=overlay_script_path)
console_service = Service(
name='Test Console',
app=None,
address='127.0.0.1',
port=8000,
debug=debug)
console_runner = ServiceRunner(
service=console_service,
file_path=console_script_path)
try:
api_runner.run()
overlay_runner.run()
console_runner.run()
while True:
sleep(1)
except KeyboardInterrupt:
api_runner.stop_running()
sleep(1)
overlay_runner.stop_running()
sleep(1)
console_runner.stop_running()