From d1b4399a089dec09dbcff209a3a654277b8dcd89 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Sat, 17 May 2025 23:35:53 +0000 Subject: [PATCH 1/2] feat(start): added container starter/stopper script --- start.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 start.py diff --git a/start.py b/start.py new file mode 100644 index 00000000..a8c76fee --- /dev/null +++ b/start.py @@ -0,0 +1,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() From 8c5d27f7a3eca3c3515e92d6673d6ceb9e0cc6d1 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Sat, 17 May 2025 23:40:47 +0000 Subject: [PATCH 2/2] docs: add start.py docs --- README.md | 6 ++++++ docs/SELF-HOSTING.md | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1089900e..d85bd25f 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,12 @@ cd suna python setup.py ``` +3. **Start or stop the containers**: + +```bash +python start.py +``` + ### Manual Setup See the [Self-Hosting Guide](./docs/SELF-HOSTING.md) for detailed manual setup instructions. diff --git a/docs/SELF-HOSTING.md b/docs/SELF-HOSTING.md index ec1c8c03..f9f8aa02 100644 --- a/docs/SELF-HOSTING.md +++ b/docs/SELF-HOSTING.md @@ -199,7 +199,9 @@ Suna can be started in two ways: This method starts all required services in Docker containers: ```bash -docker compose up -d +docker compose up -d # Use `docker compose down` to stop it later +# or +python start.py # Use the same to stop it later ``` ### 2. Manual Startup