diff --git a/bin/actions/docker.py b/bin/actions/service.py similarity index 87% rename from bin/actions/docker.py rename to bin/actions/service.py index 1feabd3..b2df543 100755 --- a/bin/actions/docker.py +++ b/bin/actions/service.py @@ -72,6 +72,20 @@ def cmd_logs(args): return run_docker_compose(cmd, service_name=args.service) +def check_service_running(service_name): + """Check if service has running containers""" + compose_file = get_service_path(service_name) + if not compose_file: + return False + + result = subprocess.run( + ["docker", "compose", "-f", compose_file, "ps", "--quiet"], + capture_output=True, + text=True + ) + + return bool(result.stdout.strip()) + def cmd_list(args): """List available Docker services""" if not os.path.exists(SERVICES_DIR): @@ -86,9 +100,12 @@ def cmd_list(args): printfe("yellow", "No Docker services found") return 0 - println("Available Docker services:") + println("Available Docker services:", 'blue') for service in sorted(services): - println(f" - {service}") + is_running = check_service_running(service) + status = "[RUNNING]" if is_running else "[STOPPED]" + color = "green" if is_running else "red" + printfe(color, f" - {service:<20} {status}") return 0 diff --git a/bin/dotf b/bin/dotf index 8962e3d..ec94936 100755 --- a/bin/dotf +++ b/bin/dotf @@ -45,9 +45,9 @@ def auto_start(args): """Run the auto-start action""" return run_script(f"{DOTFILES_BIN}/actions/auto-start.py", args) -def docker(args): - """Run the docker action""" - return run_script(f"{DOTFILES_BIN}/actions/docker.py", args) +def service(args): + """Run the service/docker action""" + return run_script(f"{DOTFILES_BIN}/actions/service.py", args) def ensure_git_hooks(): """Ensure git hooks are correctly set up""" @@ -103,7 +103,7 @@ def main(): "hello": hello, "secrets": secrets, "auto-start": auto_start, - "docker": docker + "service": service } if command in commands: