如果您认为这不是 SE 的适当部分,可以在哪里发布这样的问题,请告诉我应该将其放在哪里,我会移动它。
反正。我git daemon
在我的 OS X 机器上设置了一个在 launchd 下运行的设备,这是里面的 .plist 文件/Library/LaunchDaemons/
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.git.daemon</string>
<key>UserName</key>
<string>git-ro</string>
<key>GroupName</key>
<string>git-ro</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/git</string>
<string>daemon</string>
<string>--inetd</string>
<string>--reuseaddr</string>
<string>--verbose</string>
<string>--base-path=/Users/git/GitRepositories/</string>
<string>/Users/git/GitRepositories/</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>git</string>
<key>SockType</key>
<string>stream</string>
<key>SockFamily</key>
<string>IPv4</string>
</dict>
</dict>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
</dict>
</plist>
一切都像一个魅力,但守护进程将其信息记录到/var/log/system.log
. 有没有办法告诉它将其信息(stdout、stderr)记录到专用文件中,例如/var/log/git.log
?
编辑:我也尝试将StandardOutPath
andStandardErrPath
键添加到 .plist,但是这样做会使 launchd 无法启动 git 守护进程,原因我不知道(我在 中看到了Service could not initialize:
for git 守护进程/var/log/system.log
):
...
<key>StandardOutPath</key>
<string>/var/log/git.log</string>
<key>StandardErrorPath</key>
<string>/var/log/git.log</string>
...
编辑:我编辑了 .plist 文件,守护程序使用此配置(StandardOutPath、StandardErrorPath 似乎也有问题)。这是工作的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.git.daemon</string>
<key>UserName</key>
<string>git-ro</string>
<key>GroupName</key>
<string>staff</string>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/git</string>
<string>daemon</string>
<string>--inetd</string>
<string>--reuseaddr</string>
<string>--verbose</string>
<string>--base-path=/Users/git/GitRepositories/</string>
<string>/Users/git/GitRepositories/</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>git</string>
<key>SockType</key>
<string>stream</string>
<key>SockFamily</key>
<string>IPv4</string>
</dict>
</dict>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
</dict>
</plist>
现在,我怎样才能将守护进程的日志重定向到一个像 eg 的文件中/var/log/git.log
?