A production server generates a lot of logs, so it is necessary to rotate said logs. Logrotate is the main tool in SlapOS.
This tutorial explains how to add a logrotate entry inside the instances of your software release for remote monitoring.
Here are the commits introducing this functionality to html5as Software release: commit diff
In instance_html5as.cfg.in, add a logrotate entry for Nginx logs. Note the we use the post command as recommended in Nginx documentation to reopen log after rotation.
instance_html5as.cfg.in
Log rotation can be further customized, you can check the list of parameter in instance-logrotate-base.cfg.in
# Monitor Stack also provides logrotate stack. We only need to extend # the logrotate-entry-base defined in instance-logrotate-base.cfg.in . # More parameters can be added following the logrotate-entry-base section [logrotate-entry-nginx] <= logrotate-entry-base name = nginx log = ${html5as:path_access_log} ${html5as:path_error_log} post = kill -USR1 $(cat ${html5as:path_pid})
Add the new section to the list of parts to be processed in instance_html5as.cfg.in
[buildout] parts = ... logrotate-entry-nginx ...
Refer How To Move to md5sum automatic update to update md5sum:
md5sum
$ cd ~/srv/project/slapos/software/html5as-base $ ../../update-hash
logrotate.d
Re-compile the software by
$ slapos node software --all
Once it completes, you may re-instantiate it by
$ slapos node instance --all
Check the output to make sure it has been deployed and installed.
Change directory:
$ cd ~/srv/runner/instance/slappart0/
List the content in logrotate.d/
logrotate.d/
$ ls etc/logrotate.d/
The content inside will be:
crond monitor-apache monitor.data monitor.service.status nginx
You may also browse EXPLORER to locate logrotate.d directory.