mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-06 08:04:13 +00:00
[Update] 增加task最大允许事件,并设置命令最大运行时间为60s
This commit is contained in:
@@ -4,6 +4,7 @@ import subprocess
|
||||
|
||||
from django.conf import settings
|
||||
from celery import shared_task, subtask
|
||||
from celery.exceptions import SoftTimeLimitExceeded
|
||||
from django.utils import timezone
|
||||
|
||||
from common.utils import get_logger, get_object_or_none
|
||||
@@ -38,11 +39,14 @@ def run_ansible_task(tid, callback=None, **kwargs):
|
||||
logger.error("No task found")
|
||||
|
||||
|
||||
@shared_task
|
||||
@shared_task(soft_time_limit=60)
|
||||
def run_command_execution(cid, **kwargs):
|
||||
execution = get_object_or_none(CommandExecution, id=cid)
|
||||
if execution:
|
||||
execution.run()
|
||||
try:
|
||||
execution.run()
|
||||
except SoftTimeLimitExceeded:
|
||||
print("HLLL")
|
||||
else:
|
||||
logger.error("Not found the execution id: {}".format(cid))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user