Tutorial for additional Logorate settings for Seafile server (seafdav, seaf-fuse)

I didn’t recognize that Seafile settings for Logrotate don’t rotate the logs for seafdav or seaf-fuse (for example).

Here is a list of settings for all log files under seafile/logs:

Logrotate settings for Seafile server

This tutorial is an idea for improving https://manual.seafile.com/deploy/using_logrotate.html.

touch /etc/logrotate.d/seafile

To add (additional) settings for logrotate paste or append in /etc/logrotate.d/seafile for…

…ccnet.log

/srv/seafile/logs/ccnet.log
{
    daily
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    sharedscripts
    postrotate
            [ ! -f /srv/seafile/pids/ccnet.pid ] || kill -USR1 `cat /srv/seafile/pids/ccnet.pid`
    endscript
}

…controller.log (not in official manual)

/srv/seafile/logs/controller.log
{
    daily
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seafdav.log (not in official manual)

/srv/seafile/logs/seafdav.log
{
    daily
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seaf-fuse.log (not in official manual)

/srv/seafile/logs/seaf-fuse.log.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seafile.init.log

/srv/seafile/logs/seafile.init.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seafile.log (not in official manual)

/srv/seafile/logs/seafile.log
{
    daily
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seaf-server.log

/srv/seafile/logs/seaf-server.log
{
    daily
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    sharedscripts
    postrotate
            [ ! -f /srv/seafile/pids/seaf-server.pid ] || kill -USR1 `cat /srv/seafile/pids/seaf-server.pid`
    endscript
}

…seahub_django_request.log (not in official manual)

/srv/seafile/logs/seahub_django_request.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seahub.init.log

/srv/seafile/logs/seahub.init.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

…seahub.log (not in official manual)

/srv/seafile/logs/seahub.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

meanings (examples)

Based on: http://www.linuxcommand.org/man_pages/logrotate8.html

daily

Log files are rotated every day.

monthly

Log files are rotated the first time logrotate is run in a month (this is normally on the first day of the month).

rotate X

Log files are rotated X times before being removed or mailed to the address specified in a mail directive. If X is 0, old versions are removed rather then rotated.

backup of original /etc/logrotate.d/seafile

/srv/seafile/logs/seaf-server.log
{
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        sharedscripts
        postrotate
                [ ! -f /srv/seafile/pids/seaf-server.pid ] || kill -USR1 `cat /srv/seafile/pids/seaf-server.pid`
        endscript
}

/srv/seafile/logs/ccnet.log
{
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        sharedscripts
        postrotate
                [ ! -f /srv/seafile/pids/ccnet.pid ] || kill -USR1 `cat /srv/seafile/pids/ccnet.pid`
        endscript
}

/srv/seafile/logs/seafile.init.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}

/srv/seafile/logs/seahub.init.log
{
    monthly
    missingok
    rotate 24
    compress
    delaycompress
    notifempty
    sharedscripts
}
1 Like

@Jonathan/Seafile devs:

I didn’t get in which case you used 24 or 52 as value for rotate? Is this just a setting of personal experience or based on some system I don’t understand yet?

@all:

Comments/improvements welcome!

They’re just based on experience or common sense. You can adjust the value based on your needs.

1 Like

Is this for server v6? I’m running 5.1.8 and I neither have seaf-server.log, seafile.init.log, nor seahub.init.log.
What about the owner of the logfiles? Don’t you need to specify a create statement, like

create 0640 seafile seafile

Well I noticed the “problem” running v6 already but I don’t think that these init files were added with v6 firstly.

But do you have configs for these log files in /etc/logrotate.d/seafile?

No. The logs should be owned by seafile:seafile (in my case) already.

No, there wasn’t a seafile config file in /etc/logrotate.d.
We startetd with seafile server v3, upgraded to v4, and finally to pro 5.1.8. Maybe the upgrade scripts never created that file.

Ah sorry you have to activate logrotate for Seafile first: https://manual.seafile.com/deploy/using_logrotate.html

But this doesn’t explain that you don’t have the log files.

I have been doing this on all the log files, which seems to be working fine for the past 3 months.

/home/seafile/seafile/logs/*.log
{
    weekly
    missingok
    rotate 2
    compress
    delaycompress
    notifempty
    sharedscripts
    maxage 60
    prerotate
        /etc/init.d/seafile-server stop; sleep 10
    endscript
    postrotate
        /etc/init.d/seafile-server start
    endscript
}

It seems more simple to stop the server, rotate and then start the server again. This only leaves seafile down for around 15 seconds, which suits my personal file storage fine. Of course, if it requires zero downtime, or 99% uptime then:

[ ! -f /srv/seafile/pids/ccnet.pid ] || kill -USR1 `cat /srv/seafile/pids/ccnet.pid`

Would be needed.

2 Likes

I think seafile.init.log and seahub.init.log are only created if you use the init script from this manual:
https://manual.seafile.com/deploy/start_seafile_at_system_bootup.html

I also don’t have a logfile called seaf-server.log (using Seafile-Server 6.0.6).

Best, Bernie_O.

1 Like

Thanks, I’m using the init script. So this is the reason.

In my Installation (6.0.7 pro) I do also have these logs:
elasticsearch_index_indexing_slowlog.log
elasticsearch_index_search_slowlog.log
elasticsearch.log
index.log
seafevents.log
seahub_email_sender.log
seahub.log

My guess is to just add them as mentioned above. But for seahub.log, do I also need to send kill signal USR1?

Thanks and best regards,
Jochen

No you don’t. Only seafile.log and ccnet.log requires sending a signal. In later versions we’ll also provide rotation for controller.log, which requires a signal too. C programs requires that. For elastic search, you’d better refer to their documentation.

Thank yo Jonathan for clarification!
Ups, I already added logrotation for controller.log without sending signal. Can I send signal just according to ccnet.log?

[Edit]
Hm, don’t think so, there is no pid file for seahub, at least not in pids directory!?

Thanks and best regards,
Jochen