forked from uncloud/uncloud
59 lines
No EOL
1.7 KiB
Python
59 lines
No EOL
1.7 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import multiprocessing as mp
|
|
import logging
|
|
|
|
from os.path import join as join_path
|
|
from ucloud.sanity_checks import check
|
|
|
|
if __name__ == "__main__":
|
|
arg_parser = argparse.ArgumentParser(prog='ucloud',
|
|
description='Open Source Cloud Management Software')
|
|
arg_parser.add_argument('component',
|
|
choices=['api', 'scheduler', 'host',
|
|
'filescanner', 'imagescanner',
|
|
'metadata'])
|
|
arg_parser.add_argument('component_args', nargs='*')
|
|
args = arg_parser.parse_args()
|
|
|
|
logging.basicConfig(
|
|
level=logging.DEBUG,
|
|
filename=join_path("logs.txt"),
|
|
filemode="a",
|
|
format="%(name)s %(asctime)s: %(levelname)s - %(message)s",
|
|
datefmt="%d-%b-%y %H:%M:%S",
|
|
)
|
|
try:
|
|
check()
|
|
|
|
if args.component == 'api':
|
|
from ucloud.api.main import main
|
|
|
|
main()
|
|
elif args.component == 'host':
|
|
from ucloud.host.main import main
|
|
|
|
hostname = args.component_args
|
|
mp.set_start_method('spawn')
|
|
main(*hostname)
|
|
elif args.component == 'scheduler':
|
|
from ucloud.scheduler.main import main
|
|
|
|
main()
|
|
elif args.component == 'filescanner':
|
|
from ucloud.filescanner.main import main
|
|
|
|
main()
|
|
elif args.component == 'imagescanner':
|
|
from ucloud.imagescanner.main import main
|
|
|
|
main()
|
|
elif args.component == 'metadata':
|
|
from ucloud.metadata.main import main
|
|
|
|
main()
|
|
|
|
except Exception as e:
|
|
logging.exception(e)
|
|
print(e) |