rotating debug.txt log

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

rotating debug.txt log

by FreeLikeGNU » Post

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: 228
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

Re: rotating debug.txt log

by FreeLikeGNU » Post

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

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

Re: rotating debug.txt log

by Jay » Post

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: 228
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

Re: rotating debug.txt log

by FreeLikeGNU » Post

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: 3166
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

Re: rotating debug.txt log

by Calinou » Post

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: 4577
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: rotating debug.txt log

by Krock » Post

Image
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

Re: rotating debug.txt log

by rubenwardy » Post

I chuckled, Krock.

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

Re: rotating debug.txt log

by ExeterDad » Post

Krock wrote:Image
Simple and elegant approach.
+1

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests