perf: 终断批量快捷命令执行的任务

This commit is contained in:
wangruidong
2024-02-19 14:47:32 +08:00
committed by Bryan
parent f592f19b08
commit 135fb7c6f9
4 changed files with 42 additions and 1 deletions

View File

@@ -554,6 +554,15 @@ class JobExecution(JMSOrgBaseModel):
finally:
ssh_tunnel.local_gateway_clean(runner)
def stop(self):
with open(os.path.join(self.private_dir, 'local.pid')) as f:
try:
pid = f.read()
os.kill(int(pid), 9)
except Exception as e:
print(e)
self.set_error('Job stop by "kill -9 {}"'.format(pid))
class Meta:
verbose_name = _("Job Execution")
ordering = ['-date_created']