feat: add check function

This commit is contained in:
Moritz 2024-05-14 00:10:07 +02:00
parent 87202f9072
commit 2cfbf4a589
1 changed files with 19 additions and 0 deletions

View File

@ -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()