我在 OSX 上运行 dnsmasq。
我还使用 newsyslog 来轮换日志文件。这里是/etc/newsyslog.d/dnsmasq.conf
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/dnsmasq.log nobody:admin 640 5 10000 * Z
日志正确旋转,但当发生这种情况时,会将一行写入新的日志文件,但所有日志记录都会停止,直到我重新启动dnsmasq
。
Nov 2 15:30:00 nexus newsyslog[1932]: logfile turned over due to size>10000K
最后,这是我的/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/dnsmasq/sbin/dnsmasq</string>
<string>--keep-in-foreground</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
知道如何最好地解决这个问题吗?
答案1
您需要向 dnsmasq.conf 添加 pid_file 和 sig_num,如下所示:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/dnsmasq.log nobody:admin 640 5 10000 * Z /var/run/dnsmasq.pid 31
sig_num 31 是 SIGUSR2,它将告诉 dnsmasq 关闭并重新打开其日志文件。