-
Notifications
You must be signed in to change notification settings - Fork 1
/
mb_runner.py
57 lines (46 loc) · 1.7 KB
/
mb_runner.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
# Copyright (C) 2022-2024 Theodore Chang
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
from multiprocessing import freeze_support
from mb import run_app, Config
def config_and_run():
config = Config()
index = 1
def next_arg():
nonlocal index
index += 1
if index >= len(sys.argv):
raise Exception("Missing argument.")
return sys.argv[index]
while index < len(sys.argv):
if sys.argv[index].startswith("c"):
config.celery = True
config.celery_config = sys.argv[index + 1 :]
break
if sys.argv[index].startswith("w"):
config.workers = int(next_arg())
elif sys.argv[index].startswith("h"):
config.host = next_arg()
elif sys.argv[index].startswith("p"):
config.port = int(next_arg())
elif sys.argv[index].startswith("o"):
config.overwrite_env = True
elif sys.argv[index].startswith("d"):
config.debug = True
index += 1
run_app(config)
if __name__ == "__main__":
freeze_support()
config_and_run()