diff --git a/alakazam.py b/alakazam.py index 33e1fe0..7f5f4c9 100755 --- a/alakazam.py +++ b/alakazam.py @@ -1123,5 +1123,24 @@ def purge_volumes(apps: List[str]) -> None: print(f"Volumes for {domain} purged") +@cli.command() +@click.option('-a', '--apps', multiple=True) +def check(apps: List[str]) -> None: + """ + Check the health status of all apps inside the selected group. + + Args: + apps (list): List of applications to be checked. + """ + group_apps = list_apps(apps) + domains = list(zip(*sum(group_apps.values(), [])))[1] + for domain in domains: + logging.info(f'check {domain}') + containers = abra("app" ,"ps", "-m", domain, machine_output=True) + for container in containers.values(): + if re.match("health: starting|unknown|unhealthy", container['status']) or container['state'] != 'running': + print(f"{domain} - {container['service name']}: {container['status']}") + + if __name__ == '__main__': cli()