From 0511e21c4ca606ba5349f8f034ce7aa23d172ca3 Mon Sep 17 00:00:00 2001 From: Minh Nguyen <34470011+minhng92@users.noreply.github.com> Date: Fri, 18 Apr 2025 22:26:43 +0700 Subject: [PATCH] Logrotate on etc/odoo-server.log (#13) * logrotate * chmod +x entrypoint.sh --- docker-compose.yml | 2 +- entrypoint.sh | 11 +++++++++++ etc/logrotate | 8 ++++++++ run.sh | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) mode change 100644 => 100755 entrypoint.sh create mode 100644 etc/logrotate diff --git a/docker-compose.yml b/docker-compose.yml index 41b845c..dc4423e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: volumes: #- /etc/timezone:/etc/timezone:ro #- /etc/localtime:/etc/localtime:ro - # - ./entrypoint.sh:/entrypoint.sh # if you want to install additional Python packages, uncomment this line! + - ./entrypoint.sh:/entrypoint.sh - ./addons:/mnt/extra-addons - ./etc:/etc/odoo restart: always # run as a service diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index f3f2a13..dcdef5c --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,6 +15,17 @@ pip3 install -r /etc/odoo/requirements.txt # sed -i 's|raise werkzeug.exceptions.BadRequest(msg)|self.jsonrequest = {}|g' /usr/lib/python3/dist-packages/odoo/http.py +# Install logrotate if not already installed +if ! dpkg -l | grep -q logrotate; then + apt-get update && apt-get install -y logrotate +fi + +# Copy logrotate config +cp /etc/odoo/logrotate /etc/logrotate.d/odoo + +# Start cron daemon (required for logrotate) +cron + DB_ARGS=() function check_config() { param="$1" diff --git a/etc/logrotate b/etc/logrotate new file mode 100644 index 0000000..1ee41eb --- /dev/null +++ b/etc/logrotate @@ -0,0 +1,8 @@ +/etc/odoo/*.log { + rotate 3 + daily + nocompress + missingok + notifempty + copytruncate +} diff --git a/run.sh b/run.sh index a76b9a4..d32e503 100644 --- a/run.sh +++ b/run.sh @@ -43,6 +43,8 @@ fi find $DESTINATION -type f -exec chmod 644 {} \; find $DESTINATION -type d -exec chmod 755 {} \; +chmod +x $DESTINATION/entrypoint.sh + # Run Odoo docker-compose -f $DESTINATION/docker-compose.yml up -d