How to make supervisord logging feature work with logrotate?

supervisord won't append new logs to the new log file created by logrotate after the rotation, this is because the file descriptor (fd) does not change within the running supervisord process. To make supervisor close current log file (both for child process log files and the supervisord itself) and reopen, send a SIGUSR2 to supervisord. For detail, see documentation.

/var/log/some_application/*.log {
        daily
        dateext
        dateformat .%Y-%m-%d
        dateyesterday
        missingok
        rotate 32767
        compress
        delaycompress
        notifempty
        create 0644 root root
        sharedscripts
        postrotate
                [ -s /var/run/some-app-supervisord.pid ] && kill -USR2 `cat /var/run/some-app-supervisord.pid`
        endscript
}

A postrotate block in logrotate config should solve the problem. [ -s filename ] means to test whether there were a file named with "filename" and its size is greater than zero.

此条目发表在未分类分类目录。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据