Page 1 of 1

rotating debug.txt log

PostPosted: Fri Nov 14, 2014 05:12
by FreeLikeGNU
I'm running a couple minetestserver instances and I would like to rotate the logs. I made the following logrotate (running in ubuntu 14.04) script:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
home/minetestuser/.minetest/debug.txt {
        daily
        missingok
        rotate 12
        compress
        delaycompress
        notifempty
        sharedscripts
}


the log seems to have rotated ok as there is now a debug.txt.1 and a debug.txt in the folder but the debug.txt is no longer being updated (still at 0 bytes). What am I missing?

On a related topic, can I have multiple debug.txt texts, one for each of the servers? I don't see how it is configurable on the commandline. Something like --debug mygame.txt would be cool. Currently all running instances are save to a single debug.txt.

thanks!

PS interestingly enough, there seems to be a fedora build that includes log rotation according to http://pkgs.fedoraproject.org/cgit/mine ... c?id2=HEAD

it seems this is not done in the ubuntu package...

Re: rotating debug.txt log

PostPosted: Fri Nov 14, 2014 05:47
by FreeLikeGNU
ah just found --logfile parameter, so that solves one problem ^^
viewtopic.php?id=3057

I made logs with the world name and .log suffix and changed my logrotate script to process *.log

Re: rotating debug.txt log

PostPosted: Sat Nov 15, 2014 08:03
by Jay
What I think is happening is that Minetest is still writing to the old log file.

As I understand it, the way log rotation typically works is that logrotate renames the log file and then sends a SIGUSR1 to the daemon process. After logrotae renames the log file, the daemon's log file descriptor still points to the old, but now renamed file. Upon receiving a SIGUSR1, the daemon closes the file descriptor, and opens its log file by name, creating a new log file.

For this to work, the server will need to respond the signal as described, which I doubt Minetest supports. Also, there needs to be a way to find the server pids and send SIGUSR1s to them.

Re: rotating debug.txt log

PostPosted: Sat Nov 15, 2014 18:45
by FreeLikeGNU
Jay, thanks for the info. I think the way Fedora gets around it is with systemd managing logs. I don't know if anyone wants to make MT dependant on systemd though!

I guess another way might be sighup as shown here: https://domsch.com/blog/?p=592 I have not tested that method, and I don't know how that would work with multiple minetestserver instances running from screens.

I've also read that sigusr1 you mentioned is a better approach than sighup for being "less harsh"(?), but I don't know much about how either of those work.

Re: rotating debug.txt log

PostPosted: Sun Nov 16, 2014 09:07
by Calinou
You can use a cron job to:
  • stop the server,
  • move debug.txt to debug.txt.<something>
  • optionally, make a world backup, generate a map,
  • start the server.

Re: rotating debug.txt log

PostPosted: Sun Nov 16, 2014 10:10
by Krock
Image

Re: rotating debug.txt log

PostPosted: Sun Nov 16, 2014 10:18
by rubenwardy
I chuckled, Krock.

Re: rotating debug.txt log

PostPosted: Sun Nov 16, 2014 11:03
by ExeterDad
Krock wrote:Image

Simple and elegant approach.
+1