Git
systemd 下的 git-daemon:基本路徑不存在或不是目錄
我正在嘗試
git
使用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 $
git-daemon@.service:
$ cat /etc/systemd/system/git-daemon@.service [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 $
有人可以幫忙嗎?
我發現
User=nobody
必須將其更改為User=git
/etc/systemd/system/git-daemon@.service才能解決問題。