test
This commit is contained in:
@@ -113,17 +113,15 @@ class Framework:
|
|||||||
timezone='Asia/Seoul'
|
timezone='Asia/Seoul'
|
||||||
)
|
)
|
||||||
from celery import bootsteps
|
from celery import bootsteps
|
||||||
#from celery.bin.base import CeleryOption
|
|
||||||
from click import Option
|
from click import Option
|
||||||
|
celery.user_options['worker'].add(Option(('--config_filepath',), help=''),)
|
||||||
#from celery.bin import Option # 4.3.0
|
celery.user_options['worker'].add(Option(('--running_type',), help=''),)
|
||||||
celery.user_options['worker'].add(
|
|
||||||
Option(('--config_filepath',), help='')
|
|
||||||
)
|
|
||||||
class CustomArgs(bootsteps.Step):
|
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
|
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)
|
celery.steps['worker'].add(CustomArgs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error('CELERY!!!')
|
self.logger.error('CELERY!!!')
|
||||||
@@ -227,8 +225,7 @@ class Framework:
|
|||||||
print(sys.argv)
|
print(sys.argv)
|
||||||
if os.environ.get('RUNNING_TYPE') == 'docker':
|
if os.environ.get('RUNNING_TYPE') == 'docker':
|
||||||
self.config['running_type'] = 'docker'
|
self.config['running_type'] = 'docker'
|
||||||
else:
|
|
||||||
self.config['running_type'] = 'native'
|
|
||||||
self.__process_args()
|
self.__process_args()
|
||||||
self.__load_config()
|
self.__load_config()
|
||||||
self.__init_define()
|
self.__init_define()
|
||||||
@@ -242,17 +239,8 @@ class Framework:
|
|||||||
self.app.config['TEMPLATES_AUTO_RELOAD'] = True
|
self.app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
self.app.config['JSON_AS_ASCII'] = False
|
self.app.config['JSON_AS_ASCII'] = False
|
||||||
elif mode == 'system_loading_after':
|
elif mode == 'system_loading_after':
|
||||||
pass
|
if 'running_type' not in self.config:
|
||||||
#from system import SystemModelSetting
|
self.config['running_type'] = 'native'
|
||||||
"""
|
|
||||||
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'
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def __init_define(self):
|
def __init_define(self):
|
||||||
@@ -281,7 +269,9 @@ class Framework:
|
|||||||
for tmp in sys.argv:
|
for tmp in sys.argv:
|
||||||
if tmp.startswith('--config_filepath'):
|
if tmp.startswith('--config_filepath'):
|
||||||
self.config['arg_config'] = tmp.split('=')[1]
|
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'] =
|
#self.config['arg_config'] =
|
||||||
|
|
||||||
@@ -299,7 +289,7 @@ class Framework:
|
|||||||
# 도커는 celery가 먼저 진입
|
# 도커는 celery가 먼저 진입
|
||||||
# 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
|
# 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
|
||||||
#if self.config.get('running_type') == 'docker':
|
#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(
|
shutil.copy(
|
||||||
os.path.join(self.path_app_root, 'files', 'config.yaml.docker'),
|
os.path.join(self.path_app_root, 'files', 'config.yaml.docker'),
|
||||||
self.config['config_filepath']
|
self.config['config_filepath']
|
||||||
@@ -319,7 +309,7 @@ class Framework:
|
|||||||
# self.logger.info(f"CELERY config : {self.config['config_filepath']}")
|
# self.logger.info(f"CELERY config : {self.config['config_filepath']}")
|
||||||
data = read_yaml(self.config['config_filepath'])
|
data = read_yaml(self.config['config_filepath'])
|
||||||
for key, value in data.items():
|
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
|
continue
|
||||||
self.config[key] = value
|
self.config[key] = value
|
||||||
|
|
||||||
|
|||||||
61
native
Normal file
61
native
Normal file
@@ -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']
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user