我试图使用git-daemon通过git propocol启用对我的托pipeGitLab服务器的访问。 如果我从命令行运行git-daemon,它按预期工作:
$ /usr/libexec/git-core/git-daemon --export-all --base-path=/var/opt/gitlab/git-data/repositories --syslog --verbose $ git ls-remote git://localhost/cm/test_project.git 9cbff8accfa291ffeb8189f114c6d290a3856511 HEAD 2817d289674481ef02f05c3558063a5239d844b2 refs/heads/develop2 9cbff8accfa291ffeb8189f114c6d290a3856511 refs/heads/master bce85bd749a69cb127bdb0e64c173e926eb77cbc refs/heads/old-master $
但是,如果我以systemd单元运行git-daemon ,我得到以下错误:
$ git ls-remote git://localhost/cm/test_project.git fatal: read error: Connection reset by peer $
并在日志中:
git-daemon[19089]: base-path '/var/opt/gitlab/git-data/repositories' does not exist or is not a directory
我有以下设置:
混帐daemon.socket:
$ cat /etc/systemd/system/git-daemon.socket [Unit] Description=Git Activation Socket [Socket] ListenStream=0.0.0.0:9418 Accept=true [Install] WantedBy=sockets.target $
git的守护进程@。服务:
$ cat /etc/systemd/system/[email protected] [Unit] Description=Git Repositories Server Daemon Documentation=man:git-daemon(1) [Service] User=nobody ExecStart=-/usr/libexec/git-core/git-daemon --export-all --base-path=/var/opt/gitlab/git-data/repositories --syslog --verbose StandardInput=socket $
港口9418是可利用的:
$ netstat -nap | grep 9418 tcp 0 0 0.0.0.0:9418 0.0.0.0:* LISTEN 1/systemd $
目录存在:
$ stat /var/opt/gitlab/git-data/repositories File: '/var/opt/gitlab/git-data/repositories' Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fc01h/64513d Inode: 226543354 Links: 46 Access: (2770/drwxrws---) Uid: ( 500/ git) Gid: ( 500/ git) Access: 2017-06-09 13:13:16.514659543 +0000 Modify: 2017-04-22 23:28:16.227301854 +0000 Change: 2017-04-22 23:28:16.227301854 +0000 Birth: - $
OS是CentOS 7 ,git版本是1.8.3.1
$ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) $ git --version git version 1.8.3.1 $
任何人都可以请帮忙?
为了解决这个问题,我发现User=nobody需要更改为/etc/systemd/system/[email protected]中的User=git 。