-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq-backend-logs
34 lines (26 loc) · 861 Bytes
/
q-backend-logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# =========================================================================
#
# Begins streaming the logs per each kubernetes pod independently and
# collects them to separate files. Filters particular log entries out
# before storing them, if needs.
#
# Copyright (C) 2024 Ildar Shaimordanov
# MIT License
#
# =========================================================================
. ~/.q-func.bash
. ~/.q-decl.bash
pods=( $( q prod backend names ) )
[ ${#pods[@]} -gt 0 ] || {
echo "No pods found" >&2
exit 1
}
logger='. ~/.q-func.bash ; . ~/.q-decl.bash ; q prod logs "X" -f'
[ $# -gt 0 ] && logger="$logger"' | grep "$@"'
logger="$logger"' | tee "X.log"'
printf '%s\n' "${pods[@]}" \
| xargs -P "${#pods[@]}" -r -IX bash \
-c "$logger" - "$@"
# =========================================================================
# EOF