haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.25k stars 1.54k forks source link

Logrotate - controller.log #1387

Closed andi-blafasl closed 5 years ago

andi-blafasl commented 9 years ago

I would like to rotate the logs files from seafile with logrotate. It could be as simple as

/srv/seafile/logs/*.log
{
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    sharedscripts
    postrotate
            [ ! -f /srv/seafile/pids/ccnet.pid ] || kill -USR1 `cat /srv/seafile/pids/ccnet.pid`
            [ ! -f /srv/seafile/pids/seaf-server.pid ] || kill -USR1 `cat /srv/seafile/pids/seaf-server.pid`
            [ ! -f /srv/seafile/pids/seafdav.pid ] || kill -USR1 `cat /srv/seafile/pids/seafdav.pid`
            [ ! -f /srv/seafile/seafile-server-latest/runtime/seahub.pid ] || kill -USR1 `cat /srv/seafile/seafile-srver-latest/runtime/seahub.pid`
    endscript
}

But the controller.log file, which is used by ccnet, seaf-server and seafdav is not reopened after kill -USR1. lsof shows pids with access to the rotated controller.log.1 file

Because of this, you have to use the following postrotate script:

/etc/init.d/seafile-server restart

which will cause the seafile server to completely restart with a short interruption for the clients

BTW: why is the seahub.pid not in the top level /pids/ directory?

andi-blafasl commented 9 years ago

just discovered that doing kill -USR1 'cat /srv/seafile/seafile-srver-latest/runtime/seahub.pid' is a bad idea. It does not tell seahub to reopen it's log files. It kills seahub...

Any Idea how to get seahub working with logrotate? (without restarting after rotation ;-)

shoeper commented 9 years ago

I don't think it is possible with seahub. See http://manual.seafile.com/deploy/using_logrotate.html You could stop seahub rotate the log and start seahub.

andi-blafasl commented 9 years ago

I know this entry in the manual, but to me it seems to be outdated because it does not cover all log files created by seafile. And the possibility to reopen logs by SIGUSR1, but not reopening all log files used looks also inconsistent to me.

as a workaround you have to use this logrotate config:

/srv/seafile/logs/*.log
{
    weekly
    missingok
    rotate 4
    compress
    delaycompress
    notifempty
    sharedscripts
    postrotate
        /etc/init.d/seafile-server restart
    endscript
}
shoeper commented 9 years ago

The other logfiles were available at that point, too. Seafile works with different components. Those log files you can reopen with SIGUSR1 have nothing to do with those from seahub. If this is also possible in python you could propose a fix.

andi-blafasl commented 9 years ago

The dokumentation covers

and

I'm running version 4.3 and there are the following logs ccnet.log

seafile.log

seafdav.log

controller.log

  -> I call this a bug and think it should be fixed

seahub.log seahub_django_request.log

  -> I call this a bug and think it should be fixed
  -> should be possible, because seafdav does this already

I'm not a python programmer and can not help directly with code fixes. But I'm a linux sysadmin with long time experience in running server systems ;-)

LeonardoGentile commented 7 years ago

Yes, the docs are not very clear on this: https://manual.seafile.com/deploy/using_logrotate.html it is not up to date with the current file structure and standard log names used as @andi-blafasl said.

andi-blafasl commented 7 years ago

Right now I'm using the following code in my logrotate scrtipt

{
    weekly
    missingok
    rotate 2
    compress
    notifempty
}

/srv/seafile/logs/ccnet.log
/srv/seafile/logs/seafile.log
/srv/seafile/logs/seafdav.log
/srv/seafile/logs/seahub.log
/srv/seafile/logs/seahub_django_request.log
/srv/seafile/logs/controller.log
{
    weekly
    missingok
    rotate 4
    compress
    delaycompress
    notifempty
    sharedscripts
    postrotate
        # double stop only needed for Ubuntu 14.04
        /etc/init.d/seafile-server stop; sleep 10; /etc/init.d/seafile-server stop; sleep 10 ; /etc/init.d/seafile-server start
        # simple restart used on Debian 7.11
        #/etc/init.d/seafile-server restart
    endscript
}

The double "stop" on Ubuntu 14.04 is needed because seafile does not stop all process with a simple restart or stop and won't start afterwards. I tried do wait longer between stop and start, but the only way to get it working was the line above.

LeonardoGentile commented 7 years ago

I see but which one is the correct approach, this one or the one from the docs?

andi-blafasl commented 7 years ago

For me it is my approach ;-) Because it covers all log files that seafile creates. The approach from the manual does not cover seafdav.log seahub.log seahub_django_request.log controller.log But I'm not sure about any side effects that seafile suffers from the restarts. Maybe some caches are cleared or something like that. I do not restart MySQL, so any caches on the DB backend should be fine :-)

philthynz commented 7 years ago

I still don't see why we can't just rotate them all. There are other log files that need to be rotated... eventually.

My log dir contains:

controller.log
elasticsearch_index_indexing_slowlog.log
elasticsearch_index_search_slowlog.log
elasticsearch.log
seafevents.log
seafile.init.log
seafile.log
seahub_django_request.log
seahub.init.log
seahub.log

And i rotate them like:


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

I ran into some issues with /etc/init.d/seafile-server restart, sometimes, not sure why but the server does not stop.

freeplant commented 5 years ago

Logrotate of controller.log already supported.