Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop process bug #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion task/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __str__(self):
return self.task.name + '-' + str(self.index)

def kill(self):
os.kill(self.pid, signal.SIGKILL)
os.kill(self.pid, signal.SIGINT)

def delete_log_file(self):
if os.path.isfile(self.log_file_path):
Expand Down
9 changes: 5 additions & 4 deletions task/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
def generate_ssh_cmd(host, user, exec_cmd, private_key_path=None):
exec_cmd = exec_cmd.replace('$', '\\$')
if private_key_path is None:
cmd = "ssh -o StrictHostKeyChecking=no {}@{} \"{}\"".format(user, host, exec_cmd)
cmd = "ssh -tt -o StrictHostKeyChecking=no {}@{} \"{}\"".format(user, host, exec_cmd)
else:
cmd = "ssh -o StrictHostKeyChecking=no -i {} {}@{} \"{}\"".format(private_key_path, user, host, exec_cmd)
cmd = "ssh -tt -o StrictHostKeyChecking=no -i {} {}@{} \"{}\"".format(private_key_path, user, host, exec_cmd)
return cmd


Expand All @@ -32,7 +32,7 @@ def __init__(self, user, host, cmd, workspace="~", private_key_path=None, output
if output_file is not None:
self.output_file = output_file
with open(self.output_file, "wb") as out:
self.proc = subprocess.Popen(self.cmd, shell=True, stdout=out, stderr=out, bufsize=1)
self.proc = subprocess.Popen(self.cmd, shell=True, stdin=subprocess.PIPE, stdout=out, stderr=out, bufsize=1)
else:
self.proc = subprocess.Popen(self.cmd, shell=True)

Expand All @@ -41,7 +41,8 @@ def pid(self):

def kill(self):
# os.killpg(os.getpgid(self.proc.pid), signal.SIGKILL)
os.kill(self.proc.pid, signal.SIGKILL)
# os.kill(self.proc.pid, signal.SIGKILL)
self.proc.send_signal(signal.SIGINT)

def get_return_code(self):
self.proc.wait()
Expand Down