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.

49 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. 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. ## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm
  12. DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME"
  13. file_put "$DST" <<EOF
  14. /var/log/docker/$SERVICE_NAME/*error.log
  15. /var/log/docker/$SERVICE_NAME/*access.log
  16. {
  17. weekly
  18. missingok
  19. dateext
  20. dateyesterday
  21. dateformat _%Y-%m-%d
  22. extension .log
  23. rotate 52
  24. compress
  25. delaycompress
  26. notifempty
  27. create 640 root root
  28. sharedscripts
  29. postrotate
  30. docker-send-signal \$${MASTER_BASE_CHARM_NAME^^}_NAME SIGUSR1;
  31. endscript
  32. }
  33. EOF
  34. config-add "\
  35. $MASTER_TARGET_CHARM_NAME:
  36. volumes:
  37. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  38. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  39. $MASTER_BASE_CHARM_NAME:
  40. volumes:
  41. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  42. "