fork 0k-charms
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.

44 lines
959 B

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