#!/usr/bin/env bash # logs.sh [--target data|crawl] [-n 200] [--no-follow] # service → target is inferred (worker, worker-b → crawl; everything else → data). source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" svc="${1:-}"; [[ -n $svc ]] || die "usage: logs.sh [--target data|crawl] [-n N] [--no-follow]" shift target="$(target_for_service "$svc")"; n=200; follow="-f" while [[ $# -gt 0 ]]; do case "$1" in --target) target="$2"; shift ;; -n) n="$2"; shift ;; --no-follow) follow="" ;; *) die "unknown flag $1" ;; esac shift done check_target "$target" exec ssh -t "${SSH_OPTS[@]}" "$(host_for "$target")" "$(compose_prefix "$target") logs --tail=$n $follow $svc"