rotating debug.txt log

User avatar
FreeLikeGNU
Member
 
Posts: 119
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:

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

User avatar
FreeLikeGNU
Member
 
Posts: 119
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: 119
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
Member
 
Posts: 3124
Joined: Mon Aug 01, 2011 14:26
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
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: rotating debug.txt log

by Krock » Sun Nov 16, 2014 10:10

Image
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: rotating debug.txt log

by rubenwardy » Sun Nov 16, 2014 10:18

I chuckled, Krock.
 

User avatar
ExeterDad
Member
 
Posts: 1121
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad

Re: rotating debug.txt log

by ExeterDad » Sun Nov 16, 2014 11:03

Krock wrote:Image

Simple and elegant approach.
+1
٩(̾●̮̮̃̾•̃̾)۶

Kibbie and I have a beautiful public server now! HOMETOWN
 


Return to Minetest Servers

Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests

cron