镜像服务器端配置:
1.镜像服务器下载代码( /opt/workspace/code)
repo init -u ssh://yourname@主服务IP地址:29418/platform/manifest -b branch/xxx -m xxx.manifest --mirror
repo sync -c
2.修改/opt/workspace/code目录下的manifest.git/config文件
[daemon]
uploadpack=true
uploadarch=true
recievepack=true
3.git-daemon设置为开机自启动
(for Ubuntu 14.04)
修改/etc/init/local-git-daemon.conf文件
加入:
start on startup
stop on shutdown
exec /usr/bin/git daemon \
--user=$machine --group=$machine \
--reuseaddr \
--export-all \
--base-path=/opt/workspace/code \
/opt/workspace/code
respawn
启动: initctl start local-git-daemon
(for Ubuntu 16.04)
修改/lib/systemd/system/git-daemon.service文件
加入:
[Unit]
Description=Start Git Daemon
[Service]
ExecStart=/usr/bin/git daemon --reuseaddr --verbose --export-all --base-path=/opt/workspace/code
/opt/workspace/code
Restart=always
RestartSec=500ms
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=git-daemon
User=$machine
Group=$machine
[Install]
WantedBy=multi-user.target
启动:
sudo systemctl enable git-daemon.service
#sudo systemctl stop git-daemon.service
sudo systemctl start git-daemon.service
#systemctl daemon-reload
4.定时同步代码(updateCode.sh为服务端同步代码命令)
在/etc/crontab里面增加:
28 8-22/1 * * * root sh /home/mirror/updateCode.sh >> /home/mirror/updateCode.log 2>&1
客户端下载代码方法:
1. repo init -u git://镜像服务器IP地址/manifest -b branch/xxx -m xxx.xml
repo sync -c
2.修改git push地址
[url "ssh://主服务器IP地址:29418/platform/manifest"]
pushInsteadof=git://镜像服务器IP地址/manifest
手动启动git-daemon方法:
export CODE_PATH=/opt/workspace/code
git daemon --reuseaddr --verbose --export-all --base-path=$CODE_PATH $CODE_PATH