Skip to content

Commit

Permalink
fix(devbox): gracefull start and stop
Browse files Browse the repository at this point in the history
  • Loading branch information
arunmathaisk committed Dec 17, 2024
1 parent 5f0119e commit d839375
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions agent/devbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def delete_devbox_home_volume(self):

@step("Run Devbox")
def run_devbox(self):
try:
self.execute(f"docker stop {self.devbox_name}")
self.execute(f"docker rm {self.devbox_name}")
except Exception:
pass
command = (
f'docker run --security-opt="no-new-privileges=false" -d --rm --name {self.devbox_name} '
f"-p {self.websockify_port}:6969 "
Expand All @@ -104,8 +109,11 @@ def run_devbox(self):

@step("Stop Devbox")
def stop_devbox(self):
self.execute(command=f"docker stop {self.devbox_name}")
return self.execute(f"docker rm -f {self.devbox_name}")
try:
self.execute(command=f"docker stop {self.devbox_name}")
return self.execute(f"docker rm -f {self.devbox_name}")
except Exception:
pass

def get_devbox_status(self):
command = f"docker inspect --format='{{{{.State.Status}}}}' {self.devbox_name}"
Expand Down

0 comments on commit d839375

Please sign in to comment.