我想知道是否有人针对这种情况有更好的策略。
我目前在与网络服务器相同的机器上托管我自己的远程 git 存储库。
所有git repos 都在git 用户下。
sudo -uwww-data -gwww-data git --git-dir=/var/www/website/.git --work-tree=/var/www/website pull
我有一个 cron 作业每分钟以 root 身份运行以执行此命令。 web 文件夹中的 git repo 从同一个盒子克隆到 git 的主目录,而不是通过 ssh 存储它。
所以我的问题是:由于 git 不拥有 web 文件,因此它无法使用 git hook 移动站点。我会假设我不希望 git 有 sudo,也不会通过 git hook 工作,对吧?有没有什么东西可以比每分钟更快地部署站点?我不希望手术非常昂贵。
是否有某种根守护进程可以运行并监听某种通知?比如让它查看文件的最后修改时间?
最佳答案
请注意 this article (in French, translated through Google) sudo 与您的方法配合使用的报告:
change
sudo
to allow thegitosis
user to use this command aswww-data
.
To do this, by running "visudo" add the line:
git ALL = (www-data) NOPASSWD: /usr/local/bin/pullhere
Then, in each repository where necessary, add the next hook in a
post-receive
file:
sudo -u www-data /usr/local/bin/pullhere /html/u/user/here
eg in
/ home/git/repositories/projet1.git/hooks/post-receive
关于linux - 使用 Git 自动部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9061067/