mirror of
https://github.com/overleaf/toolkit.git
synced 2025-04-19 15:28:06 +02:00
Logs script
This commit is contained in:
parent
c31666cbd0
commit
920bea32ca
1 changed files with 67 additions and 0 deletions
67
bin/logs
67
bin/logs
|
@ -1,3 +1,70 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DEFAULT_LINES=20
|
||||
|
||||
function usage() {
|
||||
echo "Usage: bin/logs [OPTIONS] [SERVICES...]"
|
||||
echo ""
|
||||
echo "Services: chat, clsi, contacts, docstore, document-updater,"
|
||||
echo " filestore, notifications, real-time, spelling,"
|
||||
echo " tags, track-changes, web"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f follow log output"
|
||||
echo " -n {number} number of lines to print (default $DEFAULT_LINES)"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo ""
|
||||
echo " bin/logs -n 50 web clsi"
|
||||
echo ""
|
||||
echo " bin/logs -f web"
|
||||
echo ""
|
||||
echo " bin/logs -f web chat docstore"
|
||||
echo ""
|
||||
echo " bin/logs -n 100 -f filestore "
|
||||
echo ""
|
||||
echo " bin/logs -f"
|
||||
}
|
||||
|
||||
function __main__() {
|
||||
LINES="$DEFAULT_LINES"
|
||||
FOLLOW_FLAG=""
|
||||
|
||||
if [[ "$1" == "help" ]] || [[ "$1" == "--help" ]]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
while getopts "fn:" opt
|
||||
do
|
||||
case $opt in
|
||||
f ) FOLLOW_FLAG="-f" ;;
|
||||
n ) LINES="${OPTARG}" ;;
|
||||
\?) usage && exit ;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND -1 ))
|
||||
|
||||
log_base_path="/var/log/sharelatex"
|
||||
|
||||
declare -a services
|
||||
IFS=" " read -r -a services <<< "$*"
|
||||
|
||||
path_spec="$log_base_path/*.log"
|
||||
|
||||
if [[ ! "0" == "${#services[@]}" ]]; then
|
||||
log_paths=()
|
||||
for service in "${services[@]}"; do
|
||||
log_paths+=("$log_base_path/${service}.log")
|
||||
done
|
||||
path_spec="${log_paths[*]}"
|
||||
fi
|
||||
|
||||
bash_exec_command_string="tail $FOLLOW_FLAG -n $LINES $path_spec"
|
||||
|
||||
exec ./bin/docker-compose exec sharelatex bash -c "$bash_exec_command_string"
|
||||
}
|
||||
|
||||
__main__ "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue