diff --git a/apps/assets/tasks/const.py b/apps/assets/tasks/const.py index 83775d908..61a9580ed 100644 --- a/apps/assets/tasks/const.py +++ b/apps/assets/tasks/const.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- # import os + +from django.conf import settings from django.utils.translation import ugettext_lazy as _ -PERIOD_TASK_ENABLED = os.environ.get("PERIOD_TASK", "on") == 'on' +ENV_PERIOD_TASK = os.environ.get("PERIOD_TASK", "on") == 'on' +PERIOD_TASK_ENABLED = settings.PERIOD_TASK_ENABLED and ENV_PERIOD_TASK UPDATE_ASSETS_HARDWARE_TASKS = [ { diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index d89415eed..9825eaece 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -391,6 +391,7 @@ defaults = { 'WINDOWS_SSH_DEFAULT_SHELL': 'cmd', 'FLOWER_URL': "127.0.0.1:5555", 'DEFAULT_ORG_SHOW_ALL_USERS': True, + 'PERIOD_TASK_ENABLED': True, } diff --git a/apps/jumpserver/settings.py b/apps/jumpserver/settings.py index c446508f1..b0db8dbab 100644 --- a/apps/jumpserver/settings.py +++ b/apps/jumpserver/settings.py @@ -650,3 +650,6 @@ CHANNEL_LAYERS = { }, }, } + +# Enable internal period task +PERIOD_TASK_ENABLED = CONFIG.PERIOD_TASK_ENABLED diff --git a/jms b/jms index ff949e2d5..0cf4a1171 100755 --- a/jms +++ b/jms @@ -415,6 +415,10 @@ def get_daemon_context(): files_preserve.append(daemon_log_f) context = daemon.DaemonContext( pidfile=pidfile.TimeoutPIDLockFile(daemon_pid_file), + signal_map={ + signal.SIGTERM: lambda x, y: clean_up(), + signal.SIGHUP: 'terminate', + }, stdout=daemon_log_f, stderr=daemon_log_f, files_preserve=files_preserve,