我正在将git守护进程作为windows服务运行。(使用创建流程(
服务中使用的命令是:
git daemon --reuseaddr --base-path=/data/test_work/ --export-all
--verbose --enable=receive-pack
在哪里可以看到git daemon
的日志?
注意:/var/logs
没有文件。
如果你仍然需要并想这样做,我已经找到了一种方法:只需创建一个具有执行权限的bash脚本,并告诉守护进程将其内容记录到一个或两个文件中(如果你想单独记录stderr(:
#!/bin/bash
# Git daemon launchd startup command.
GIT_RO_USER="git-ro" # The user which has read only access to the repositories.
GIT_REP_BASE_PATH="/path/to/GitRepositories" # The repositories base path.
GIT_LOG_FILE="/var/log/git.log" # The git daemon log file. The user which runs the script must have the right write permissions
/path/to/git daemon --reuseaddr --verbose --user=$GIT_RO_USER --base-path=$GIT_REP_BASE_PATH $GIT_REP_BASE_PATH >> $GIT_LOG_FILE 2>&1
# Or if you like to keep the error log separated, uncomment the following lines and comment the previous one:
#GIT_ERR_LOG_FILE="/var/log/git_err.log" # The error log file
#/path/to/git daemon --reuseaddr --verbose --user=$GIT_RO_USER --base-path=$GIT_REP_BASE_PATH $GIT_REP_BASE_PATH >> $GIT_LOG_FILE 2>> $GIT_ERR_LOG_FILE
其中/path/to/git
是git命令的路径。我在OSX机器上与launchd
一起使用它,因为我注意到您不能使用.plist文件为守护进程设置StandardOutPath
和StandardErrorPath
密钥。
希望它也能帮助你!
在哪里可以看到git守护进程的日志?
Git 2.17(2018年第一季度(可能会有所帮助,因为来自"git daemon
"的日志可以通过一个新选项重定向;一个相关的用例是在从inetd
运行日志时,将日志发送到标准错误(而不是syslog(。
参见Lucas Werkmeister(lucaswerkmeister
(提交的0c591ca(2018年2月4日(
帮助:Ævar ArnfjörğBjarmason(avar
(、Junio C Hamano(gitster
(和Eric Sunshine(sunshineco
(
(由Junio C Hamano合并——gitster
——提交c2bd43d,2018年2月21日(
daemon
:增加--log-destination=(stderr|syslog|none)
此新选项可用于覆盖
--inetd
的隐式--syslog
,或禁用所有日志记录。(虽然--detach
也意味着--syslog
,但具有--detach
的--log-destination=stderr
是无用的,因为--detach
将进程与原始stderr解除关联。(--syslog
被保留为--log-destination=syslog
的别名。
--log-destination
始终覆盖隐式--syslog
,而不管期权订单
这与"最后一个获胜"的逻辑不同适用于Git中其他地方的一些隐含选项,但希望不要那么令人困惑
(我也不知道Git中的所有隐式选项是否都遵循"最后一个获胜"。(
--inetd
和--log-destination=stderr
的组合对于实例,当将git daemon
作为实例systemd
服务运行时(带相关插座单元(
在这种情况下,通过syslog
发送的日志消息由日志守护程序接收,但在git daemon
进程已经退出时(尤其是在进程非常短暂的情况下,例如由于客户端错误(,日志守护程序可能会面临被处理的风险,因此日志守护程序无法再读取其cgroup
将消息附加到正确的systemd
单元(请参阅systemd/systemd第2913期(。相反,登录到stderr
可以解决这个问题,因为systemd
可以将stderr
直接连接到日志守护进程,而该守护进程已经知道哪个单元与该流相关联。
Git 2.18(2018年第二季度(使事情变得更加健壮,因为最近在"git daemon
"中引入的"--log-destination
"选项在守护进程以"--inetd
"模式运行时效果不佳。
daemon.c
:修复重定向stderr
的条件由于
--log-destination
选项是在0c591ca中添加的("daemon:add--log-destination=(stderr|syslog|none)
",2018-02-04,Git 2.17(明确的目标是在inetd
模式下运行时允许日志记录到stderr
,我们不应该总是在inetd模式下将stderr
重定向到/dev/null
,而应该仅在stderr
不用于日志记录时。