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.

52 lines
1.3 KiB

  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/apache2
  6. ## XXXvlab: hum it seems apache logging is run as root, so well...
  7. # logs_creds=$(cached_cmd_on_base_image apache "stat -c '%u %g' '$LOGS'") || {
  8. # debug "Failed to query for www-data gid in ${DARKYELLOW}apache${NORMAL} base image."
  9. # return 1
  10. # }
  11. rotated_count=$(relation-get rotated-count 2>/dev/null) || true
  12. rotated_count=${rotated_count:-52}
  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/*error.log
  17. /var/log/docker/$SERVICE_NAME/*access.log
  18. {
  19. weekly
  20. missingok
  21. dateext
  22. dateyesterday
  23. dateformat _%Y-%m-%d
  24. extension .log
  25. rotate $rotated_count
  26. compress
  27. delaycompress
  28. notifempty
  29. create 640 root root
  30. sharedscripts
  31. postrotate
  32. docker-send-signal \$${MASTER_BASE_CHARM_NAME^^}_NAME SIGUSR1;
  33. endscript
  34. }
  35. EOF
  36. config-add "\
  37. $MASTER_TARGET_CHARM_NAME:
  38. volumes:
  39. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  40. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  41. $MASTER_BASE_CHARM_NAME:
  42. volumes:
  43. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  44. "