forked from anoncoder9/Kemono2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_uwsgi_config.py
52 lines (39 loc) · 1.25 KB
/
generate_uwsgi_config.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
import textwrap
from src.config import Configuration
def generate():
opts = Configuration().webserver['uwsgi_options'].items()
opts = '\n'.join(list(f'{k} = {v}' for k, v in opts))
config_str = f'''
[uwsgi]
processes = { Configuration().webserver['workers'] }
http = 0.0.0.0:{ Configuration().webserver['port'] }
{'py-autoreload = 1' if Configuration().development_mode else ''}
{opts}
strict = true
master = true
vacuum = true
single-interpreter = true
die-on-term = true
need-app = true
lazy-apps = true
enable-threads = true
; Worker recycling.
max-requests = 0
max-worker-lifetime = 3600
reload-on-rss = 2048
worker-reload-mercy = 60
; Harakiri (Longest amount of time an active worker can run without killing itself)
harakiri = 60
manage-script-name = true
mount = /=server:app
listen = 1000
post-buffering = true
buffer-size = 8192
'''
config_str = textwrap.dedent(config_str)
config_str = config_str.strip()
config_str += '\n'
with open('uwsgi.ini', 'w') as f:
f.write(config_str)
if __name__ == '__main__':
generate()