Set up logrotate for server

How it works

seaf-server, ccnet-server (since version 3.1) and seafile-controller (since version 6.0.8) support reopenning
logfiles by receiving a SIGUR1 signal.

This feature is very useful when you need cut logfiles while you don’t want
to shutdown the server. All you need to do now is cutting the logfile on the fly.

NOTE: signal is not supported by windows, so the feature is not available there.

Default logrotate configuration directory

For debian, the default directory for logrotate should be /etc/logrotate.d/

Sample configuration

Assuming your ccnet-server’s logfile is /home/haiwen/logs/ccnet.log and your
ccnet-server’s pidfile for ccnet-server is /home/haiwen/pids/ccnet.pid.

Assuming your seaf-server’s logfile is setup to /home/haiwen/logs/seafile.log and your
seaf-server’s pidfile for seaf-server is setup to /home/haiwen/pids/seaf-server.pid:

The configuration for logrotate could be like this:

  1. /home/haiwen/logs/seafile.log
  2. {
  3. daily
  4. missingok
  5. rotate 15
  6. compress
  7. delaycompress
  8. notifempty
  9. sharedscripts
  10. postrotate
  11. [ ! -f /home/haiwen/pids/seaf-server.pid ] || kill -USR1 `cat /home/haiwen/pids/seaf-server.pid`
  12. endscript
  13. }
  14. /home/haiwen/logs/ccnet.log
  15. {
  16. daily
  17. missingok
  18. rotate 15
  19. compress
  20. delaycompress
  21. notifempty
  22. sharedscripts
  23. postrotate
  24. [ ! -f /home/haiwen/pids/ccnet.pid ] || kill -USR1 `cat /home/haiwen/pids/ccnet.pid`
  25. endscript
  26. }
  27. /home/haiwen/logs/index.log
  28. {
  29. monthly
  30. missingok
  31. rotate 15
  32. compress
  33. delaycompress
  34. notifempty
  35. sharedscripts
  36. }

You can save this file, in debian for example, at /etc/logrotate.d/seafile.