update
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from flask import abort, request
|
from flask import abort, request
|
||||||
@@ -45,14 +46,15 @@ class CustomFormatter(logging.Formatter):
|
|||||||
green = "\x1B[32m"
|
green = "\x1B[32m"
|
||||||
# pathname filename
|
# pathname filename
|
||||||
#format = "[%(asctime)s|%(name)s|%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
#format = "[%(asctime)s|%(name)s|%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"
|
||||||
format = '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset} %(pathname)s:%(lineno)s] {color}%(message)s{reset}'
|
|
||||||
|
__format = '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset} %(pathname)s:%(lineno)s] {color}%(message)s{reset}' if os.environ.get('LOGGER_PATHNAME', "False") == "True" else '[{yellow}%(asctime)s{reset}|{color}%(levelname)s{reset}|{green}%(name)s{reset} %(filename)s:%(lineno)s] {color}%(message)s{reset}'
|
||||||
|
|
||||||
FORMATS = {
|
FORMATS = {
|
||||||
logging.DEBUG: format.format(color=grey, reset=reset, yellow=yellow, green=green),
|
logging.DEBUG: __format.format(color=grey, reset=reset, yellow=yellow, green=green),
|
||||||
logging.INFO: format.format(color=green, reset=reset, yellow=yellow, green=green),
|
logging.INFO: __format.format(color=green, reset=reset, yellow=yellow, green=green),
|
||||||
logging.WARNING: format.format(color=yellow, reset=reset, yellow=yellow, green=green),
|
logging.WARNING: __format.format(color=yellow, reset=reset, yellow=yellow, green=green),
|
||||||
logging.ERROR: format.format(color=red, reset=reset, yellow=yellow, green=green),
|
logging.ERROR: __format.format(color=red, reset=reset, yellow=yellow, green=green),
|
||||||
logging.CRITICAL: format.format(color=bold_red, reset=reset, yellow=yellow, green=green)
|
logging.CRITICAL: __format.format(color=bold_red, reset=reset, yellow=yellow, green=green)
|
||||||
}
|
}
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ class Framework:
|
|||||||
self.config['path_app'] = self.config['path_app'][0].upper() + self.config['path_app'][1:]
|
self.config['path_app'] = self.config['path_app'][0].upper() + self.config['path_app'][1:]
|
||||||
self.path_app_root = self.config['path_app']
|
self.path_app_root = self.config['path_app']
|
||||||
self.config['path_working'] = os.getcwd()
|
self.config['path_working'] = os.getcwd()
|
||||||
if os.environ.get('RUNNING_TYPE') == 'docker':
|
if os.environ.get('RUNNING_TYPE', None) != None:
|
||||||
self.config['running_type'] = 'docker'
|
self.config['running_type'] = os.environ.get('RUNNING_TYPE')
|
||||||
self.config['export_filepath'] = os.path.join(self.config['path_app'], 'export.sh')
|
self.config['export_filepath'] = os.path.join(self.config['path_app'], 'export.sh')
|
||||||
self.config['exist_export'] = os.path.exists(self.config['export_filepath'])
|
self.config['exist_export'] = os.path.exists(self.config['export_filepath'])
|
||||||
self.__process_args()
|
self.__process_args()
|
||||||
@@ -262,13 +262,15 @@ class Framework:
|
|||||||
self.__init_define()
|
self.__init_define()
|
||||||
self.config['menu_yaml_filepath'] = os.path.join(self.config['path_data'], 'db', 'menu.yaml')
|
self.config['menu_yaml_filepath'] = os.path.join(self.config['path_data'], 'db', 'menu.yaml')
|
||||||
self.config['notify_yaml_filepath'] = os.path.join(self.config['path_data'], 'db', 'notify.yaml')
|
self.config['notify_yaml_filepath'] = os.path.join(self.config['path_data'], 'db', 'notify.yaml')
|
||||||
|
if 'running_type' not in self.config:
|
||||||
|
self.config['running_type'] = 'native'
|
||||||
|
|
||||||
elif mode == "flask":
|
elif mode == "flask":
|
||||||
self.app.secret_key = os.urandom(24)
|
self.app.secret_key = os.urandom(24)
|
||||||
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':
|
||||||
if 'running_type' not in self.config:
|
pass
|
||||||
self.config['running_type'] = 'native'
|
|
||||||
|
|
||||||
|
|
||||||
def __init_define(self):
|
def __init_define(self):
|
||||||
@@ -316,8 +318,7 @@ class Framework:
|
|||||||
# celery는 환경변수 사용불가로 native 판단
|
# celery는 환경변수 사용불가로 native 판단
|
||||||
# 도커는 celery가 먼저 진입
|
# 도커는 celery가 먼저 진입
|
||||||
# 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
|
# 추후에 변경할 것!!!!!!!!!!!!!!!!! TODO
|
||||||
#if self.config.get('running_type') == 'docker':
|
if self.config.get('running_type').startswith('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']
|
||||||
@@ -452,7 +453,7 @@ class Framework:
|
|||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
host = '0.0.0.0'
|
host = '0.0.0.0'
|
||||||
for i in range(10):
|
for i in range(5):
|
||||||
try:
|
try:
|
||||||
#self.logger.debug(d(self.config))
|
#self.logger.debug(d(self.config))
|
||||||
# allow_unsafe_werkzeug=True termux nohup 실행시 필요함
|
# allow_unsafe_werkzeug=True termux nohup 실행시 필요함
|
||||||
@@ -477,6 +478,9 @@ class Framework:
|
|||||||
continue
|
continue
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.logger.error('KeyboardInterrupt !!')
|
self.logger.error('KeyboardInterrupt !!')
|
||||||
|
except:
|
||||||
|
self.logger.error("start error")
|
||||||
|
|
||||||
#except SystemExit:
|
#except SystemExit:
|
||||||
# return
|
# return
|
||||||
#sys.exit(self.__exit_code)
|
#sys.exit(self.__exit_code)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
VERSION="4.0.5"
|
VERSION="4.0.6"
|
||||||
@@ -36,8 +36,8 @@ class ModuleSetting(PluginModuleBase):
|
|||||||
'notify_advaned_use' : 'False',
|
'notify_advaned_use' : 'False',
|
||||||
'notify.yaml': '', #직접 사용하지 않으나 저장 편의상.
|
'notify.yaml': '', #직접 사용하지 않으나 저장 편의상.
|
||||||
'command_text': '',
|
'command_text': '',
|
||||||
'celery_start_by_web': 'False', #웹 실행시 celery 실행
|
'celery_start_by_web': 'True' if F.config['running_type'] == 'docker_alpine' else 'False', #웹 실행시 celery 실행
|
||||||
'celery_start_command': "celery -A flaskfarm.main.celery worker --loglevel=info --pool=gevent --concurrency=2 --config_filepath={F.config['config_filepath']} --running_type=native",
|
'celery_start_command': f"celery -A flaskfarm.main.celery worker --loglevel=info --pool=gevent --concurrency=2 --config_filepath={F.config['config_filepath']} --running_type={F.config['running_type']}",
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ var running_type = "{{arg['running_type']}}";
|
|||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
console.log(running_type);
|
console.log(running_type);
|
||||||
if (running_type == 'docker') {
|
if (running_type.startsWith('docker')) {
|
||||||
$('#celery_start_by_web').bootstrapToggle('off');
|
$('#celery_start_by_web').bootstrapToggle('off');
|
||||||
$('#celery_start_by_web').prop('disabled', true);
|
$('#celery_start_by_web').prop('disabled', true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user