mirror of https://github.com/jumpserver/jumpserver
fix: 添加启动失效缓存
parent
f0f493081a
commit
99cce185dd
|
@ -0,0 +1,19 @@
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
from assets.signals_handler.node_assets_mapping import expire_node_assets_mapping_for_memory
|
||||||
|
from orgs.models import Organization
|
||||||
|
|
||||||
|
|
||||||
|
def expire_node_assets_mapping():
|
||||||
|
org_ids = Organization.objects.all().values_list('id', flat=True)
|
||||||
|
org_ids = [*org_ids, '00000000-0000-0000-0000-000000000000']
|
||||||
|
|
||||||
|
for org_id in org_ids:
|
||||||
|
expire_node_assets_mapping_for_memory(org_id)
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Expire caches'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
expire_node_assets_mapping()
|
9
jms
9
jms
|
@ -97,6 +97,14 @@ def check_migrations():
|
||||||
# sys.exit(1)
|
# sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def expire_caches():
|
||||||
|
apps_dir = os.path.join(BASE_DIR, 'apps')
|
||||||
|
code = subprocess.call("python manage.py expire_caches", shell=True, cwd=apps_dir)
|
||||||
|
|
||||||
|
if code == 1:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def perform_db_migrate():
|
def perform_db_migrate():
|
||||||
logging.info("Check database structure change ...")
|
logging.info("Check database structure change ...")
|
||||||
os.chdir(os.path.join(BASE_DIR, 'apps'))
|
os.chdir(os.path.join(BASE_DIR, 'apps'))
|
||||||
|
@ -116,6 +124,7 @@ def prepare():
|
||||||
check_database_connection()
|
check_database_connection()
|
||||||
check_migrations()
|
check_migrations()
|
||||||
upgrade_db()
|
upgrade_db()
|
||||||
|
expire_caches()
|
||||||
|
|
||||||
|
|
||||||
def check_pid(pid):
|
def check_pid(pid):
|
||||||
|
|
Loading…
Reference in New Issue