加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 使用Git自动部署

发布时间:2020-12-13 23:22:41 所属栏目:Linux 来源:网络整理
导读:我想知道是否有人对这种情况有更好的策略. 我目前在与网络服务器相同的盒子上托管我自己的远程git仓库. 所有git repos都在git用户之下. sudo -uwww-data -gwww-data git --git-dir=/var/www/website/.git --work-tree=/var/www/website pull 我有一个执行此
我想知道是否有人对这种情况有更好的策略.

我目前在与网络服务器相同的盒子上托管我自己的远程git仓库.

所有git repos都在git用户之下.

sudo -uwww-data -gwww-data git --git-dir=/var/www/website/.git --work-tree=/var/www/website pull

我有一个执行此命令的每分钟以root身份运行的cron作业. Web文件夹中的git repo从同一个盒子克隆到git的home目录,而不是通过ssh存储它.

所以我的问题:由于git不拥有Web文件,因此无法使用git hook移动网站.我会假设我不希望git有sudo,也不会通过git钩子工作,对吧?是否有什么能比每分钟更快地部署网站?我不希望操作非常昂贵.

是否有某种守护进程可以运行并听取某种通知?就像让它观看文件的最后修改时间一样?

解决方法

请注意,this article (in French,translated through Google)报告sudo适用于您的方法:

change sudo to allow the gitosis user to use this command as www-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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读