git
我正在尝试使用 propocol启用对我托管的 GitLab 服务器的访问git-daemon
。如果我从命令行运行 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
$
git-daemon
但如果我以单位身份运行,systemd
我会收到以下错误:
$ 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
我有以下设置:
git-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
$
$ 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: -
$
操作系统是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
$
有人可以帮忙吗?
答案1
我发现必须User=nobody
改为User=git
/etc/systemd/系统/[电子邮件保护]以修复该问题。