forked from kortix-ai/suna
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
55 lines (47 loc) · 1.45 KB
/
start.py
File metadata and controls
55 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
import subprocess
import sys
def check_docker_compose_up():
result = subprocess.run(
["docker", "compose", "ps", "-q"],
capture_output=True,
text=True
)
return len(result.stdout.strip()) > 0
def main():
force = False
if "--help" in sys.argv:
print("Usage: ./script.py [OPTION]")
print("Manage docker-compose services interactively")
print("\nOptions:")
print(" -f\tForce start containers without confirmation")
print(" --help\tShow this help message")
return
if "-f" in sys.argv:
force = True
print("Force awakened. Skipping confirmation.")
is_up = check_docker_compose_up()
if is_up:
action = "stop"
msg = "🛑 Stop containers? [y/N] " # No default
else:
action = "start"
msg = "⚡ Start containers? [Y/n] " # Yes default
if not force:
response = input(msg).strip().lower()
if action == "stop":
# Only proceed if user explicitly types 'y'
if response != "y":
print("Aborting.")
return
else:
# Proceed unless user types 'n'
if response == "n":
print("Aborting.")
return
if action == "stop":
subprocess.run(["docker", "compose", "down"])
else:
subprocess.run(["docker", "compose", "up", "-d"])
if __name__ == "__main__":
main()