mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-16 00:52:41 +00:00
Compare commits
4 Commits
pr@dev@ter
...
v2.28.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21f2257a9f | ||
|
|
59388655ea | ||
|
|
ef7463c588 | ||
|
|
7e7d6d94e6 |
@@ -9,6 +9,10 @@ class FlowerService(BaseService):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def db_file(self):
|
||||||
|
return os.path.join(BASE_DIR, 'data', 'flower')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cmd(self):
|
def cmd(self):
|
||||||
print("\n- Start Flower as Task Monitor")
|
print("\n- Start Flower as Task Monitor")
|
||||||
@@ -20,11 +24,11 @@ class FlowerService(BaseService):
|
|||||||
'-A', 'ops',
|
'-A', 'ops',
|
||||||
'flower',
|
'flower',
|
||||||
'-logging=info',
|
'-logging=info',
|
||||||
|
'-db={}'.format(self.db_file),
|
||||||
'--url_prefix=/core/flower',
|
'--url_prefix=/core/flower',
|
||||||
'--auto_refresh=False',
|
'--auto_refresh=False',
|
||||||
'--max_tasks=1000',
|
'--max_tasks=1000',
|
||||||
'--persistent=True',
|
'--persistent=True',
|
||||||
'-db=/opt/jumpserver/data/flower.db',
|
|
||||||
'--state_save_interval=600000'
|
'--state_save_interval=600000'
|
||||||
]
|
]
|
||||||
return cmd
|
return cmd
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import ssl
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
REDIS_SSL_CA, REDIS_SSL_CERT, REDIS_SSL_KEY, REDIS_SSL_REQUIRED, REDIS_USE_SSL,
|
REDIS_SSL_CA, REDIS_SSL_CERT, REDIS_SSL_KEY, REDIS_SSL_REQUIRED, REDIS_USE_SSL,
|
||||||
REDIS_SENTINEL_SERVICE_NAME, REDIS_SENTINELS, REDIS_SENTINEL_PASSWORD,
|
REDIS_PROTOCOL, REDIS_SENTINEL_SERVICE_NAME, REDIS_SENTINELS, REDIS_SENTINEL_PASSWORD,
|
||||||
REDIS_SENTINEL_SOCKET_TIMEOUT
|
REDIS_SENTINEL_SOCKET_TIMEOUT
|
||||||
)
|
)
|
||||||
from ..const import CONFIG, PROJECT_DIR
|
from ..const import CONFIG, PROJECT_DIR
|
||||||
@@ -81,41 +81,49 @@ BOOTSTRAP3 = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Django channels support websocket
|
# Django channels support websocket
|
||||||
if not REDIS_USE_SSL:
|
REDIS_LAYERS_HOST = {
|
||||||
redis_ssl = None
|
|
||||||
else:
|
|
||||||
redis_ssl = ssl.SSLContext()
|
|
||||||
redis_ssl.check_hostname = bool(CONFIG.REDIS_SSL_REQUIRED)
|
|
||||||
if REDIS_SSL_CA:
|
|
||||||
redis_ssl.load_verify_locations(REDIS_SSL_CA)
|
|
||||||
if REDIS_SSL_CERT and REDIS_SSL_KEY:
|
|
||||||
redis_ssl.load_cert_chain(REDIS_SSL_CERT, REDIS_SSL_KEY)
|
|
||||||
|
|
||||||
REDIS_HOST = {
|
|
||||||
'db': CONFIG.REDIS_DB_WS,
|
'db': CONFIG.REDIS_DB_WS,
|
||||||
'password': CONFIG.REDIS_PASSWORD or None,
|
'password': CONFIG.REDIS_PASSWORD or None,
|
||||||
'ssl': redis_ssl,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REDIS_LAYERS_SSL_PARAMS = {}
|
||||||
|
if REDIS_USE_SSL:
|
||||||
|
REDIS_LAYERS_SSL_PARAMS.update({
|
||||||
|
'ssl': REDIS_USE_SSL,
|
||||||
|
'ssl_cert_reqs': REDIS_SSL_REQUIRED,
|
||||||
|
"ssl_keyfile": REDIS_SSL_KEY,
|
||||||
|
"ssl_certfile": REDIS_SSL_CERT,
|
||||||
|
"ssl_ca_certs": REDIS_SSL_CA
|
||||||
|
})
|
||||||
|
REDIS_LAYERS_HOST.update(REDIS_LAYERS_SSL_PARAMS)
|
||||||
|
|
||||||
if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
|
if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
|
||||||
REDIS_HOST['sentinels'] = REDIS_SENTINELS
|
REDIS_LAYERS_HOST['sentinels'] = REDIS_SENTINELS
|
||||||
REDIS_HOST['master_name'] = REDIS_SENTINEL_SERVICE_NAME
|
REDIS_LAYERS_HOST['master_name'] = REDIS_SENTINEL_SERVICE_NAME
|
||||||
REDIS_HOST['sentinel_kwargs'] = {
|
REDIS_LAYERS_HOST['sentinel_kwargs'] = {
|
||||||
'password': REDIS_SENTINEL_PASSWORD,
|
'password': REDIS_SENTINEL_PASSWORD,
|
||||||
'socket_timeout': REDIS_SENTINEL_SOCKET_TIMEOUT
|
'socket_timeout': REDIS_SENTINEL_SOCKET_TIMEOUT
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
REDIS_HOST['address'] = (CONFIG.REDIS_HOST, CONFIG.REDIS_PORT)
|
# More info see: https://github.com/django/channels_redis/issues/334
|
||||||
|
# REDIS_LAYERS_HOST['address'] = (CONFIG.REDIS_HOST, CONFIG.REDIS_PORT)
|
||||||
|
REDIS_LAYERS_ADDRESS = '{protocol}://:{password}@{host}:{port}/{db}'.format(
|
||||||
|
protocol=REDIS_PROTOCOL, password=CONFIG.REDIS_PASSWORD,
|
||||||
|
host=CONFIG.REDIS_HOST, port=CONFIG.REDIS_PORT, db=CONFIG.REDIS_DB_WS
|
||||||
|
)
|
||||||
|
REDIS_LAYERS_SSL_PARAMS.pop('ssl', None)
|
||||||
|
REDIS_LAYERS_HOST['address'] = '{}?{}'.format(REDIS_LAYERS_ADDRESS, urlencode(REDIS_LAYERS_SSL_PARAMS))
|
||||||
|
|
||||||
|
|
||||||
CHANNEL_LAYERS = {
|
CHANNEL_LAYERS = {
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'common.cache.RedisChannelLayer',
|
'BACKEND': 'common.cache.RedisChannelLayer',
|
||||||
'CONFIG': {
|
'CONFIG': {
|
||||||
"hosts": [REDIS_HOST],
|
"hosts": [REDIS_LAYERS_HOST],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ASGI_APPLICATION = 'jumpserver.routing.application'
|
ASGI_APPLICATION = 'jumpserver.routing.application'
|
||||||
|
|
||||||
# Dump all celery log to here
|
# Dump all celery log to here
|
||||||
@@ -138,7 +146,7 @@ if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
|
|||||||
CELERY_BROKER_TRANSPORT_OPTIONS = CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = SENTINEL_OPTIONS
|
CELERY_BROKER_TRANSPORT_OPTIONS = CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = SENTINEL_OPTIONS
|
||||||
else:
|
else:
|
||||||
CELERY_BROKER_URL = CELERY_BROKER_URL_FORMAT % {
|
CELERY_BROKER_URL = CELERY_BROKER_URL_FORMAT % {
|
||||||
'protocol': 'rediss' if REDIS_USE_SSL else 'redis',
|
'protocol': REDIS_PROTOCOL,
|
||||||
'password': CONFIG.REDIS_PASSWORD,
|
'password': CONFIG.REDIS_PASSWORD,
|
||||||
'host': CONFIG.REDIS_HOST,
|
'host': CONFIG.REDIS_HOST,
|
||||||
'port': CONFIG.REDIS_PORT,
|
'port': CONFIG.REDIS_PORT,
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from .terminal import Terminal
|
|||||||
from .command import Command
|
from .command import Command
|
||||||
from .. import const
|
from .. import const
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
|
||||||
@@ -37,10 +36,10 @@ class CommonStorageModelMixin(models.Model):
|
|||||||
|
|
||||||
def set_to_default(self):
|
def set_to_default(self):
|
||||||
self.is_default = True
|
self.is_default = True
|
||||||
self.save()
|
self.save(update_fields=['is_default'])
|
||||||
self.__class__.objects.select_for_update()\
|
self.__class__.objects.select_for_update() \
|
||||||
.filter(is_default=True)\
|
.filter(is_default=True) \
|
||||||
.exclude(id=self.id)\
|
.exclude(id=self.id) \
|
||||||
.update(is_default=False)
|
.update(is_default=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -128,7 +127,10 @@ class CommandStorage(CommonStorageModelMixin, CommonModelMixin):
|
|||||||
|
|
||||||
def save(self, force_insert=False, force_update=False, using=None,
|
def save(self, force_insert=False, force_update=False, using=None,
|
||||||
update_fields=None):
|
update_fields=None):
|
||||||
super().save()
|
super().save(
|
||||||
|
force_insert=force_insert, force_update=force_update,
|
||||||
|
using=using, update_fields=update_fields
|
||||||
|
)
|
||||||
|
|
||||||
if self.type in TYPE_ENGINE_MAPPING:
|
if self.type in TYPE_ENGINE_MAPPING:
|
||||||
engine_mod = import_module(TYPE_ENGINE_MAPPING[self.type])
|
engine_mod = import_module(TYPE_ENGINE_MAPPING[self.type])
|
||||||
|
|||||||
Reference in New Issue
Block a user