因為 git-daemon-run 是用 sv 來啟動的。
實際上 git-daemon 包含在git 的source code ,所以 apt install git-core 就會有 git-daemon 。
git-daemon 提供 git:// 的服務。
所以只要設定對那些 folder 提供服務,允不允許 write (push). 其他就一些 log 之類的..
跟用什麼serive manager 無關。
測試:
手動 adduser gitdaemon,然後登入 gitdaemon, run git-daemon,看看git:// 有沒有作用。
這樣就可以把gitdaemon的 HOME 作為 git repository,create new repo 也只要login 成 gitdaemon, 在 自己目錄下 clone --bare 就可以。
OK 之後再寫到 systemd service.
$ sudo adduser gitdaemon $ sudo su - gitdaemon $ mkdir repository $ cd repository $ git clone --bare /home/test/test test.git $ /usr/lib/git-core/git-daemon --export-all --verbose --enable=receive-pack --syslog --base-path=/home/gitdaemon/repository /home/gitdaemon/repository這樣,其他user 就可以:
git clone git::/127.0.0.1/testgit.git
手動 OK 後,寫 systemd service file:
$ cat /etc/systemd/system/gitdaemon.service [Unit] Description = Git Daemon Service [Service] Type=simple User=gitdaemon ExecStart=/usr/lib/git-core/git-daemon --export-all --verbose --enable=receive-pack --syslog --base-path=/home/gitdaemon/repository /home/gitdaemon/repository & [Install] WantedBy=multi-user.target新增後,enable & start,看 status:
$ sudo systemctl status gitdaemon.service ● gitdaemon.service - Git Daemon Service Loaded: loaded (/etc/systemd/system/gitdaemon.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2023-09-27 16:29:00 CST; 1min 47s ago Main PID: 8231 (git-daemon) Tasks: 1 (limit: 4915) CGroup: /system.slice/gitdaemon.service └─8231 /usr/lib/git-core/git-daemon --export-all --verbose --enable=receive-pack --syslog --base-path=/home/gitdaemon/repository /home/gitdaemon/repository & Sep 27 16:29:00 xeontitan systemd[1]: Started Git Daemon Service. Sep 27 16:29:00 xeontitan git-daemon[8231]: Ready to rumble Sep 27 16:29:32 xeontitan git-daemon[8252]: Connection from 192.168.147.182:56802 Sep 27 16:29:32 xeontitan git-daemon[8252]: Extended attribute "host": xeontitan Sep 27 16:29:32 xeontitan git-daemon[8252]: Request upload-pack for '/testgit.git' Sep 27 16:29:32 xeontitan git-daemon[8231]: [8252] Disconnected Sep 27 16:29:57 xeontitan git-daemon[8262]: Connection from 192.168.147.182:52568 Sep 27 16:29:57 xeontitan git-daemon[8262]: Extended attribute "host": xeontitan Sep 27 16:29:57 xeontitan git-daemon[8262]: Request receive-pack for '/testgit.git' Sep 27 16:29:57 xeontitan git-daemon[8231]: [8262] Disconnected這樣應該就成功了。
之後多人同時做 android 的 repo sync 時,出現 error
remote: Counting objects: 100% (128934/128934), done. remote: Compressing objects: 100% (53641/53641), done. remote: Total 128913 (delta 57825), reused 127304 (delta 56375) Fetching: 78% (792/1011) 41:10 | 10 jobs | 16:10 platform/frameworks/base @ frameworks/base fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. platform/prebuilts/android-emulator: fatal: Could not read from remote repository.查 syslog 有:
Oct 4 13:11:48 rd1-ubuntu git-daemon[1791508]: Too many children, dropping connection Oct 4 13:11:51 rd1-ubuntu git-daemon[1791508]: message repeated 3 times: [ Too many children, dropping connection]查git-daemon 的 option 說明有:
--max-connections=<n> Maximum number of concurrent clients, defaults to 32. Set it to zero for no limit.所以修改 git-daemon service:
$ cat /etc/systemd/system/gitdaemon.service [Unit] Description = Git Daemon Service [Service] Type=simple User=gitdaemon ExecStart=/usr/lib/git-core/git-daemon --export-all --verbose --enable=receive-pack --syslog --max-connections=0 --base-path=/home/gitdaemon/repository /home/gitdaemon/repository & [Install] WantedBy=multi-user.target然後做 stop, daemon-reload, start..
沒有留言:
張貼留言