In systemd: added log files and changed workingdir (#287)

* coredns log configuration for logrotate

In order to not let the log files (wrote in the systemd file) grew too much, we should move this "coredns-log.conf" file inside /etc/logrotate.d/
In this case I set 50MB of logs, splitted in 5 files, rotation occurs every time on file reaches 10MB in size, I also said to compress the file after the rotation, so even less space should be occupied,
you can change this settings with whatever configuration you prefer. :)

* Update README.md

updated readme with instruction with where to move the configuration file for coredns-log.conf

* Update README.md

* changed workingdir and added log files

sometimes using ~ in the workingdir does not work
Also I'd like to print a basic log of what's happening

* update logs in coredns.service

Changed StandardOutput and StandardError from file: to append:
(so when coredns restart logs continue to be printed)
This commit is contained in:
leonardo091800 2023-08-11 20:14:06 +02:00 committed by GitHub
parent 8e996f5d44
commit d222a8e478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -10,3 +10,4 @@ In order to work, you need to do following jobs:
- Put `Corefile` at `/etc/coredns/Corefile`
- Put `coredns-sysusers.conf` in `/usr/lib/sysusers.d`
- Put `coredns-tmpfiles.conf` in `/usr/lib/tmpfiles.d`
- Put `coredns-log.conf` in `/etc/logrotate.d`

13
systemd/coredns-log.conf Normal file
View file

@ -0,0 +1,13 @@
/var/log/coredns.log {
rotate 5
size 10M
compress
notifempty
}
/var/log/coredns.err.log {
rotate 5
size 10M
compress
notifempty
}

View file

@ -11,10 +11,13 @@ CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=coredns
WorkingDirectory=~
WorkingDirectory=/var/lib/coredns
ExecStart=/usr/bin/coredns -conf=/etc/coredns/Corefile
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure
StandardOutput=append:/var/log/coredns.log
StandardError=append:/var/log/coredns.err.log
[Install]
WantedBy=multi-user.target