Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support log rotate #32

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ RUN mkdir -p /usr/local/nebula/bin
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl \
&& apt-get -qq install -y --no-install-recommends ca-certificates curl cron logrotate \
&& apt-get clean all
ADD bin/agent /usr/local/bin/agent
ADD db_playback /usr/local/nebula/bin/db_playback

ENV LOGROTATE_ROTATE= \
LOGROTATE_SIZE=

COPY bin/agent /usr/local/bin/agent
COPY db_playback /usr/local/nebula/bin/db_playback
COPY logrotate.sh /logrotate.sh
RUN echo "0 * * * * root /etc/cron.daily/logrotate" >> /etc/crontab
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY: build clean fmt test proto run examples test

DOCKER_REPO ?= docker.io/vesoft
IMAGE_TAG ?= latest


default: build

clean:
Expand All @@ -14,6 +18,12 @@ build: clean fmt
chmod +x ./bin/agent
chmod +x ./bin/client

docker-build:
docker build -t "${DOCKER_REPO}/nebula-agent:${IMAGE_TAG}" .

docker-push:
docker push "${DOCKER_REPO}/nebula-agent:${IMAGE_TAG}"

proto:
sh scripts/gen_proto.sh

Expand Down
51 changes: 51 additions & 0 deletions logrotate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/env bash

ROTATE=5
SIZE=200M

if [ -n "${LOGROTATE_ROTATE}" ]; then
ROTATE=${LOGROTATE_ROTATE}
fi

if [ -n "${LOGROTATE_SIZE}" ]; then
SIZE=${LOGROTATE_SIZE}
fi

nebula="
/usr/local/nebula/logs/graphd-stderr.log
/usr/local/nebula/logs/graphd-out.log
/usr/local/nebula/logs/nebula-graphd.INFO
/usr/local/nebula/logs/nebula-graphd.INFO.impl
/usr/local/nebula/logs/nebula-graphd.WARNING
/usr/local/nebula/logs/nebula-graphd.WARNING.impl
/usr/local/nebula/logs/nebula-graphd.ERROR
/usr/local/nebula/logs/nebula-graphd.ERROR.impl
/usr/local/nebula/logs/metad-stderr.log
/usr/local/nebula/logs/metad-out.log
/usr/local/nebula/logs/nebula-metad.INFO
/usr/local/nebula/logs/nebula-metad.INFO.impl
/usr/local/nebula/logs/nebula-metad.WARNING
/usr/local/nebula/logs/nebula-metad.WARNING.impl
/usr/local/nebula/logs/nebula-metad.ERROR
/usr/local/nebula/logs/nebula-metad.ERROR.impl
/usr/local/nebula/logs/storaged-stderr.log
/usr/local/nebula/logs/storaged-out.log
/usr/local/nebula/logs/nebula-storaged.INFO
/usr/local/nebula/logs/nebula-storaged.INFO.impl
/usr/local/nebula/logs/nebula-storaged.WARNING
/usr/local/nebula/logs/nebula-storaged.WARNING.impl
/usr/local/nebula/logs/nebula-storaged.ERROR
/usr/local/nebula/logs/nebula-storaged.ERROR.impl
{
daily
rotate ${ROTATE}
copytruncate
nocompress
missingok
notifempty
create 644 root root
size ${SIZE}
}
"

echo "${nebula}" >/etc/logrotate.d/nebula