logs not streaming for agents

This commit is contained in:
goldsquid
2025-12-13 15:45:50 +07:00
parent cfe0b50ae1
commit 6469e2cd92

29
logs.sh
View File

@@ -7,8 +7,31 @@ fi
SERVICES=$(cat /root/rpc/$1.yml | yaml2json - | jq '.services' | jq -r 'keys[]' | tr '\n' ' ')
if [ -n "$2" ]; then
docker compose logs -f --tail "$2" $SERVICES
# Check if -f flag is provided
FOLLOW_FLAG=""
TAIL_COUNT=""
# Parse arguments (skip first argument which is the compose file)
shift
for arg in "$@"; do
if [ "$arg" = "-f" ]; then
FOLLOW_FLAG="-f"
elif [[ "$arg" =~ ^[0-9]+$ ]]; then
TAIL_COUNT="$arg"
fi
done
# Build the command
if [ -n "$TAIL_COUNT" ]; then
if [ -n "$FOLLOW_FLAG" ]; then
docker compose logs -f --tail "$TAIL_COUNT" $SERVICES
else
docker compose logs --tail "$TAIL_COUNT" $SERVICES
fi
else
docker compose logs -f $SERVICES
if [ -n "$FOLLOW_FLAG" ]; then
docker compose logs -f $SERVICES
else
docker compose logs $SERVICES
fi
fi