Skip to content

Commit

Permalink
fix: agent and tendermint process kill logic
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybayblade committed May 31, 2024
1 parent fc6b3ca commit 291edf7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions operate/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import shutil
import signal
import subprocess # nosec
import time
import typing as t
from copy import deepcopy
from dataclasses import dataclass
Expand Down Expand Up @@ -427,9 +428,19 @@ def _start_tendermint(working_dir: Path) -> None:

def _kill_process(pid: int) -> None:
"""Kill process."""
if platform.platform() == "Windows":
return os.kill(pid, signal.CTRL_C_EVENT) # type: ignore
return os.kill(pid, signal.SIGKILL)
while True:
try:
os.kill(
pid,
(
signal.CTRL_C_EVENT # type: ignore
if platform.platform() == "Windows"
else signal.SIGKILL
),
)
except OSError:
return
time.sleep(3)


def _stop_agent(working_dir: Path) -> None:
Expand Down Expand Up @@ -615,7 +626,9 @@ def _build_host(self, force: bool = True) -> None:
build = self.path / DEPLOYMENT
if build.exists() and not force:
return

if build.exists() and force:
stop_host_deployment(build_dir=build)
shutil.rmtree(build)

service = Service.load(path=self.path)
Expand Down

0 comments on commit 291edf7

Please sign in to comment.