rotating debug.txt log

User avatar
FreeLikeGNU
Member
 
Posts: 125
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

rotating debug.txt log

by FreeLikeGNU » Fri Nov 14, 2014 05:12

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:

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...
 

User avatar
FreeLikeGNU
Member
 
Posts: 125
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

Re: rotating debug.txt log

by FreeLikeGNU » Fri Nov 14, 2014 05:47

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
 

Jay
Member
 
Posts: 11
Joined: Sun Sep 01, 2013 16:31

Re: rotating debug.txt log

by Jay » Sat Nov 15, 2014 08:03

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.
 

User avatar
FreeLikeGNU
Member
 
Posts: 125
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

Re: rotating debug.txt log

by FreeLikeGNU » Sat Nov 15, 2014 18:45

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.
 

User avatar
Calinou
Moderator
 
Posts: 3156
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: rotating debug.txt log

by Calinou » Sun Nov 16, 2014 09:07

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.
 

User avatar
Krock
Developer
 
Posts: 4371
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker
 

User avatar
rubenwardy
Moderator
 
Posts: 5835
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

User avatar
ExeterDad
Member
 
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
Location: New Hampshire U.S.A
In-game: ExeterDad
 


Return to Servers



Who is online

Users browsing this forum: No registered users and 7 guests