# -*- coding: utf-8 -*-
from os.path import dirname, realpath
from sys import argv

from loguru import logger
from torch import multiprocessing

from service.Dispatcher import DispatcherService
from util.LogUtils import init_log

'''
    dsp主程序入口
'''
if __name__ == '__main__':
    multiprocessing.set_start_method('spawn')
    base_dir = dirname(realpath(__file__))
    arg = argv
    print("脚本启动参数: ", arg)
    envs = ('dev', 'test', 'prod')
    env = envs[0]
    active = [env for env in envs if env in arg]
    if len(active) != 0:
        env = active[0]
    init_log(base_dir, env)
    logger.info("(♥◠‿◠)ﾉﾞ  DSP【算法调度服务】开始启动   ლ(´ڡ`ლ)ﾞ")
    DispatcherService(base_dir, env)
