-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_config.py
More file actions
123 lines (103 loc) · 3 KB
/
Copy pathgenerate_config.py
File metadata and controls
123 lines (103 loc) · 3 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
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
from pathlib import Path
import uuid
import json
template_str = """\
[unix_http_server]
file=./supervisor.sock
[supervisord]
environment=RPCHOST="127.0.0.1:2474",MINIO_ROOT_USER={MINIO_ROOT_USER},MINIO_ROOT_PASSWORD={MINIO_ROOT_PASSWORD},\
MINIO_URL={MINIO_URL},MINIO_ACCESS={MINIO_ROOT_USER},MINIO_SECRET={MINIO_ROOT_PASSWORD},\
DATABASE={DATABASE},WEBVCC_DISABLE_STATIC="",VCC_CALL_VERBOSE="true"
directory=%(here)s
childlogfile=%(here)s/log
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix://./supervisor.sock
[program:rpc]
command=python3 ./vcc_rpc/server/main.py
autorestart=true
priority=10
startretries=3
redirect_stderr=true
stdout_logfile=./log/%(program_name)s.log
[program:minio]
command=minio server ./data
autorestart=true
priority=10
startretries=3
redirect_stderr=true
stdout_logfile=./log/%(program_name)s.log
[group:services]
programs=login,chat,file,record,bot,friend
priority=20
[program:login]
startsecs=5
command=python3 ./vcc_rpc/services/login.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[program:chat]
startsecs=5
command=python3 ./vcc_rpc/services/chat.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[program:file]
startsecs=5
command=python3 ./vcc_rpc/services/file.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[program:record]
startsecs=5
command=python3 ./vcc_rpc/services/record.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[program:bot]
startsecs=5
command=python3 ./vcc_rpc/services/bot.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[program:friend]
startsecs=5
command=python3 ./vcc_rpc/services/friend.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/service_%(program_name)s.log
[group:gateways]
programs=web,bot2
priority=20
[program:web]
startsecs=5
command=python3 ./web-vcc/backend/main.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/gateway_%(program_name)s.log
[program:bot2]
startsecs=5
command=python3 ./vcc-bot/server/main.py
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=./log/gateway_%(program_name)s.log
"""
def input_with_default(prompt: str, default: str):
text = input(f"{prompt} [{default}]: ")
return text if text else default
config_str = template_str.format_map({
"MINIO_ROOT_USER": json.dumps(input_with_default("The root user name of the minio", "root")),
"MINIO_ROOT_PASSWORD": json.dumps(input_with_default("The root password of the minio", str(uuid.uuid4()).replace("-", ""))),
"MINIO_URL": json.dumps(input("The url that can be accessed by users: ")),
"DATABASE": json.dumps(input("The python code to get the database: "))
})
(Path(__file__).parent / "supervisord.conf").write_text(config_str)