mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-31 23:20:37 +00:00
perf: 修复发布机安装应用的报错
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
@@ -80,8 +82,12 @@ class AppletHostDeploymentViewSet(viewsets.ModelViewSet):
|
|||||||
objs = [model(host=host) for host in hosts_qs]
|
objs = [model(host=host) for host in hosts_qs]
|
||||||
applet_host_deployments = model.objects.bulk_create(objs)
|
applet_host_deployments = model.objects.bulk_create(objs)
|
||||||
applet_host_deployment_ids = [str(obj.id) for obj in applet_host_deployments]
|
applet_host_deployment_ids = [str(obj.id) for obj in applet_host_deployments]
|
||||||
|
task_id = str(uuid.uuid4())
|
||||||
task = run_applet_host_deployment_install_applet.delay(applet_host_deployment_ids, applet_id)
|
|
||||||
task_id = str(task.id)
|
|
||||||
model.objects.filter(id__in=applet_host_deployment_ids).update(task=task_id)
|
model.objects.filter(id__in=applet_host_deployment_ids).update(task=task_id)
|
||||||
|
transaction.on_commit(lambda: self.start_install_applet(applet_host_deployment_ids, applet_id, task_id))
|
||||||
return Response({'task': task_id}, status=201)
|
return Response({'task': task_id}, status=201)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def start_install_applet(applet_host_deployment_ids, applet_id, task_id):
|
||||||
|
run_applet_host_deployment_install_applet.apply_async((applet_host_deployment_ids, applet_id),
|
||||||
|
task_id=str(task_id))
|
||||||
|
Reference in New Issue
Block a user