#!/bin/bash
# -*- mode: sh; -*-
# vim: filetype=sh
set -eo pipefail

# This tool relies on the python package called `awslogs` (installed with `pip3 install awslogs`).

function usage {
	echo ${1}
	cat <<EOF
Usage: ${0} <component>, e.g. discovery
EOF
	exit 1
}

if [ -z ${1} ]; then
	usage "Error: no component specified"
fi

if [ -z $(which awslogs) ]; then
	echo "Error: please install the python awslogs package with \`pip3 install awslogs\`"
	exit 1
fi

awslogs get ${1}-cluster-logs ALL --watch &
trap 'kill $(jobs -pr)' SIGINT SIGTERM EXIT

while [ 1 ]; do
	sleep 1
done
