Git后挂钩挂

我有一个git post-receive hook,它构build了一个Go程序并运行它。 问题是我得到了Go程序的所有输出,并且git push “永不结束”执行,在那里被阻塞。

我正在寻找一种方法来运行Go程序而不挂上push命令。

我的收到后的文件:

 #!/bin/bash while read oldrev newrev ref do branch=`echo $ref | cut -d/ -f3` if [ "production" == "$branch" -o "master" == "$branch" ]; then ... go build exec ./webservice echo 'Pushed!' fi done 

我可以build议去(和执行?)背景与(go build ; exec ./webservice )&

如果你的git程序出现问题,你将不会被通知,所以你将需要一个日志

也许更好的解决办法是自动杀死程序,如果它太长, timeout

解决:

 nohup ./webservice > output.txt 2>&1 & 

这样,我可以将stdoutstderr到一个文件中,避免挂上git post-receive钩子。