You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

  1. #!/bin/bash
  2. ## Should be executable N time in a row with same result.
  3. . lib/common
  4. set -e
  5. odoo_uid=$(get_odoo_uid)
  6. LOGS=/var/log/odoo
  7. mkdir -p "$SERVICE_DATASTORE/$LOGS"
  8. chown -R "$odoo_uid" "$SERVICE_DATASTORE/$LOGS"
  9. rotated_count=$(relation-get rotated-count 2>/dev/null) || true
  10. rotated_count=${rotated_count:-52}
  11. ## No postrotate script as odoo uses a WatchedFileHandler log that
  12. ## close and reopen log file if it changes.
  13. ## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm
  14. DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME"
  15. file_put "$DST" <<EOF
  16. /var/log/docker/$SERVICE_NAME/odoo.log
  17. {
  18. weekly
  19. missingok
  20. dateext
  21. dateyesterday
  22. dateformat _%Y-%m-%d
  23. extension .log
  24. rotate $rotated_count
  25. compress
  26. delaycompress
  27. notifempty
  28. create 640
  29. sharedscripts
  30. }
  31. EOF
  32. config-add "\
  33. services:
  34. $MASTER_TARGET_SERVICE_NAME:
  35. volumes:
  36. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  37. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  38. $MASTER_BASE_SERVICE_NAME:
  39. volumes:
  40. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  41. command:
  42. - \"--logfile=$LOGS/odoo.log\"
  43. "