mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-15 16:42:34 +00:00
Compare commits
4 Commits
pr@dev@fea
...
v2.28.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21f2257a9f | ||
|
|
59388655ea | ||
|
|
ef7463c588 | ||
|
|
7e7d6d94e6 |
@@ -9,6 +9,10 @@ class FlowerService(BaseService):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@property
|
||||
def db_file(self):
|
||||
return os.path.join(BASE_DIR, 'data', 'flower')
|
||||
|
||||
@property
|
||||
def cmd(self):
|
||||
print("\n- Start Flower as Task Monitor")
|
||||
@@ -20,11 +24,11 @@ class FlowerService(BaseService):
|
||||
'-A', 'ops',
|
||||
'flower',
|
||||
'-logging=info',
|
||||
'-db={}'.format(self.db_file),
|
||||
'--url_prefix=/core/flower',
|
||||
'--auto_refresh=False',
|
||||
'--max_tasks=1000',
|
||||
'--persistent=True',
|
||||
'-db=/opt/jumpserver/data/flower.db',
|
||||
'--state_save_interval=600000'
|
||||
]
|
||||
return cmd
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import os
|
||||
import ssl
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from .base import (
|
||||
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
|
||||
)
|
||||
from ..const import CONFIG, PROJECT_DIR
|
||||
@@ -81,41 +81,49 @@ BOOTSTRAP3 = {
|
||||
}
|
||||
|
||||
# Django channels support websocket
|
||||
if not REDIS_USE_SSL:
|
||||
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 = {
|
||||
REDIS_LAYERS_HOST = {
|
||||
'db': CONFIG.REDIS_DB_WS,
|
||||
'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:
|
||||
REDIS_HOST['sentinels'] = REDIS_SENTINELS
|
||||
REDIS_HOST['master_name'] = REDIS_SENTINEL_SERVICE_NAME
|
||||
REDIS_HOST['sentinel_kwargs'] = {
|
||||
REDIS_LAYERS_HOST['sentinels'] = REDIS_SENTINELS
|
||||
REDIS_LAYERS_HOST['master_name'] = REDIS_SENTINEL_SERVICE_NAME
|
||||
REDIS_LAYERS_HOST['sentinel_kwargs'] = {
|
||||
'password': REDIS_SENTINEL_PASSWORD,
|
||||
'socket_timeout': REDIS_SENTINEL_SOCKET_TIMEOUT
|
||||
}
|
||||
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 = {
|
||||
'default': {
|
||||
'BACKEND': 'common.cache.RedisChannelLayer',
|
||||
'CONFIG': {
|
||||
"hosts": [REDIS_HOST],
|
||||
"hosts": [REDIS_LAYERS_HOST],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ASGI_APPLICATION = 'jumpserver.routing.application'
|
||||
|
||||
# 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
|
||||
else:
|
||||
CELERY_BROKER_URL = CELERY_BROKER_URL_FORMAT % {
|
||||
'protocol': 'rediss' if REDIS_USE_SSL else 'redis',
|
||||
'protocol': REDIS_PROTOCOL,
|
||||
'password': CONFIG.REDIS_PASSWORD,
|
||||
'host': CONFIG.REDIS_HOST,
|
||||
'port': CONFIG.REDIS_PORT,
|
||||
|
||||
@@ -19,7 +19,6 @@ from .terminal import Terminal
|
||||
from .command import Command
|
||||
from .. import const
|
||||
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
|
||||
@@ -37,10 +36,10 @@ class CommonStorageModelMixin(models.Model):
|
||||
|
||||
def set_to_default(self):
|
||||
self.is_default = True
|
||||
self.save()
|
||||
self.__class__.objects.select_for_update()\
|
||||
.filter(is_default=True)\
|
||||
.exclude(id=self.id)\
|
||||
self.save(update_fields=['is_default'])
|
||||
self.__class__.objects.select_for_update() \
|
||||
.filter(is_default=True) \
|
||||
.exclude(id=self.id) \
|
||||
.update(is_default=False)
|
||||
|
||||
@classmethod
|
||||
@@ -128,7 +127,10 @@ class CommandStorage(CommonStorageModelMixin, CommonModelMixin):
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=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:
|
||||
engine_mod = import_module(TYPE_ENGINE_MAPPING[self.type])
|
||||
|
||||
Reference in New Issue
Block a user