diff --git a/lib/framework/init_main.py b/lib/framework/init_main.py index 2a069e3..5a4587d 100644 --- a/lib/framework/init_main.py +++ b/lib/framework/init_main.py @@ -113,17 +113,15 @@ class Framework: timezone='Asia/Seoul' ) from celery import bootsteps - #from celery.bin.base import CeleryOption from click import Option - - #from celery.bin import Option # 4.3.0 - celery.user_options['worker'].add( - Option(('--config_filepath',), help='') - ) + celery.user_options['worker'].add(Option(('--config_filepath',), help=''),) + celery.user_options['worker'].add(Option(('--running_type',), help=''),) class CustomArgs(bootsteps.Step): - def __init__(self, worker, config_filepath=None, **options): + def __init__(self, worker, config_filepath=None, running_type=None, **options): from . import F - F.logger.info("celery config filepath: {config_filepath}") + F.logger.info(f"celery config_filepath: {config_filepath}") + F.logger.info(f"celery running_type: {running_type}") + #F.logger.info(f"celery running_type: {options}") celery.steps['worker'].add(CustomArgs) except Exception as e: self.logger.error('CELERY!!!') @@ -227,8 +225,7 @@ class Framework: print(sys.argv) if os.environ.get('RUNNING_TYPE') == 'docker': self.config['running_type'] = 'docker' - else: - self.config['running_type'] = 'native' + self.__process_args() self.__load_config() self.__init_define() @@ -242,17 +239,8 @@ class Framework: self.app.config['TEMPLATES_AUTO_RELOAD'] = True self.app.config['JSON_AS_ASCII'] = False elif mode == 'system_loading_after': - pass - #from system import SystemModelSetting - """ - app.config['config']['running_type'] = 'native' - if 'SJVA_RUNNING_TYPE' in os.environ: - app.config['config']['running_type'] = os.environ['SJVA_RUNNING_TYPE'] - else: - import platform - if platform.system() == 'Windows': - app.config['config']['running_type'] = 'windows' - """ + if 'running_type' not in self.config: + self.config['running_type'] = 'native' def __init_define(self): @@ -281,7 +269,9 @@ class Framework: for tmp in sys.argv: if tmp.startswith('--config_filepath'): self.config['arg_config'] = tmp.split('=')[1] - break + #break + elif tmp.startswith('--running_type'): + self.config['running_type'] = tmp.split('=')[1] #self.config['arg_config'] = @@ -299,7 +289,7 @@ class Framework: # 도커는 celery가 먼저 진입 # 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO #if self.config.get('running_type') == 'docker': - if self.config.get('running_type') == 'docker' or os.path.exists('/data'): + if self.config.get('running_type') == 'docker':# or os.path.exists('/data'): shutil.copy( os.path.join(self.path_app_root, 'files', 'config.yaml.docker'), self.config['config_filepath'] @@ -319,7 +309,7 @@ class Framework: # self.logger.info(f"CELERY config : {self.config['config_filepath']}") data = read_yaml(self.config['config_filepath']) for key, value in data.items(): - if key == 'running_type' and self.config[key] == 'native' and value not in ['termux', 'entware']: + if key == 'running_type' and value not in ['termux', 'entware']: continue self.config[key] = value diff --git a/native b/native new file mode 100644 index 0000000..054f8f3 --- /dev/null +++ b/native @@ -0,0 +1,61 @@ +# 데이터 폴더 루트 경로 +# 윈도우의 경우 폴더 구분 기호 \ 를 두개 사용 +# 예) data_folder: "C:\\work\\data" +# 현재 폴더인 경우 . +path_data: "C:\\work\\FlaskFarm\\working" +#path_data: "/mnt/c/work/FlaskFarm/working" + +# gevent 사용여부 +# 거의 항상 true로 사용. +# 플러그인 개발이나 termux 환경에서의 실행 같이 특수한 경우에만 false로 사용. +# 실행환경에 gevent 관련 패키지가 설치되어 있지 않는다면 값과 상관 없이 false로 동작. +# false인 경우 +use_gevent: true + + +# celery 사용 여부 +use_celery: true + +# redis port +# celery를 사용하는 경우 사용하는 redis 포트 +redis_port: 6379 + +# 포트 +# 생략시 DB 값을 사용. +port: 9999 + +# 소스 수정시 재로딩 +# 두번 로딩되는 것을 감안하여 코딩해야 함. 기본실행, subporcess 실행 +# 기본적으로 main.py 하위 파일의 변경만 감시 +debug: true + +use_reloader: true + +# 플러그인 업데이트 여부 +# - true인 경우 로딩시 플러그인을 업데이트 함. +# 데이터폴더/plugins 폴더 안에 플러그인 만을 대상으로 함. +# - debug 값이 true인 경우에는 항상 false +plugin_update: false + +# url subpath +url_prefix: "/sf" + +# running_type +# termux, entware 인 경우 입력 함. (이외 사용하는 값 native, docker) +running_type: "native" + + +# 개발용 폴더만 로딩할 경우 사용 +#plugin_loading_only_devpath: true + + +# 로딩할 플러그인 package 명 +# 타 플러그인과 연동되는 플러그인 개발시 사용. +# import 로 런타임에 로딩할 수 있지만 타 패키지 메뉴 등은 표시되지 않음. +#plugin_loading_list: ['command', 'flaskcode'] + + +# 로딩 제외할 플러그인 package 명 +plugin_except_list: ['terminal', 'membership'] + +