Skip to content

Commit

Permalink
[pkg] rotate log file (#3638)
Browse files Browse the repository at this point in the history
* add lumberjack

* add lograte conf in Dockerfile

* del space line
  • Loading branch information
huof6829 authored Sep 30, 2022
1 parent b94422c commit 18064e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ COPY --from=build /go/apps/iotex-core/bin/actioninjectorv2 /usr/local/bin/iotex-
COPY --from=build /go/apps/iotex-core/bin/addrgen /usr/local/bin/iotex-addrgen
COPY --from=build /go/apps/iotex-core/bin/ioctl /usr/local/bin/ioctl

CMD [ "iotex-server"]

# logrotate log file daily
RUN apk add logrotate
RUN apk add --no-cache logrotate
COPY logrotate.conf /etc/logrotate.d/iotex
RUN mkdir -p /var/lib/
RUN touch /var/lib/logrotate.status
RUN logrotate /etc/logrotate.d/iotex
RUN echo -e "#!/bin/sh\n\n/usr/sbin/logrotate -f /etc/logrotate.d/iotex" > /etc/periodic/daily/logrotate

COPY entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["iotex-server"]
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

/usr/sbin/crond

exec "$@"
4 changes: 4 additions & 0 deletions logrotate.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
nocompress
missingok
copytruncate
notifempty
dateext
dateformat -%Y-%m-%d
extension .log
}

0 comments on commit 18064e2

Please sign in to comment.