Skip to content

Commit 340a64f

Browse files
committed
feat: stop local on dev run and vice versa
1 parent 6a87af7 commit 340a64f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tutor/commands/compose.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from tutor.exceptions import TutorError
2121
from tutor.tasks import BaseComposeTaskRunner
2222
from tutor.types import Config
23+
from tutor.utils import check_output
2324

2425

2526
class ComposeTaskRunner(BaseComposeTaskRunner):
@@ -33,9 +34,12 @@ def docker_compose(self, *command: str) -> int:
3334
"""
3435
Run docker-compose with the right yml files.
3536
"""
36-
if "start" in command or "up" in command or "restart" in command:
37-
# Note that we don't trigger the action on "run". That's because we
38-
# don't want to trigger the action for every initialization script.
37+
if self.project_name not in str(
38+
check_output("docker", "compose", "ls")
39+
) and any(word in command for word in ("start", "up", "restart", "run")):
40+
# We would trigger the action if project is not currently running
41+
# Running it would always stop previously running project
42+
# So there is no need to trigger this action in that case
3943
hooks.Actions.COMPOSE_PROJECT_STARTED.do(
4044
self.root, self.config, self.project_name
4145
)

0 commit comments

Comments
 (0)