通过Gitolite部署节点应用程序和后接收挂钩 [英] Deploying Node Apps via Gitolite and post-receive hook

查看:132
本文介绍了通过Gitolite部署节点应用程序和后接收挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Gitolite来获取一个相当简单的部署流程来使用Node应用程序。我有Gitolite的设置和在我的服务器上工作,我可以推到很好。

I'm trying to get a fairly simple deploy process going for a Node app using Gitolite. I have Gitolite setup and working on my server, and I'm able to push to it fine.

Gitolite运行在用户名为 git ,我已经设置了一个节点用户,我希望用来运行Node应用程序。

Gitolite is running under a user called git, and I've setup a node user that I'm hoping to use to run the Node app.

我的计划是将Node应用程序推送到Gitolite,然后使用后接收钩子脚本将应用程序文件移动到应用程序所在的目录,在这种情况下 / VAR /本地/节点应用程序/我的节点,应用程序/ 。我创建了这样的Node应用程序文件夹:

My plan is to push the Node app to Gitolite, and then use a post-receive hook script to move the app files to the directory where the app lives, in this case /var/local/node-apps/my-node-app/. I created the Node app folder like this:

sudo mkdir -p /var/local/node-apps/my-node-app
sudo chown node /var/local/node-apps/my-node-app

问题是我是一个Unix noob,我没有得到我的头文件/文件夹权限和wotnot。

The problem is that I'm a Unix noob and I haven't got my head round file/folder permissions and wotnot.

/ var / local / node-apps (以及 / var / local / node-apps / my-node-app )由 node user,所以当 git 用户尝试检出到这个位置时,我得到一堆权限被拒绝的错误。我在接收后使用的命令是:

/var/local/node-apps (and also /var/local/node-apps/my-node-app) is owned by the node user, so when the git user tries to checkout to this location I get a bunch of permission denied errors. The command I'm using in the post-receive is:

GIT_WORK_TREE=/var/local/node-apps/my-node-app git checkout -f

我收到这样的错误:

remote: error: git checkout-index: unable to create file XXXX (Permission denied)
remote: fatal: cannot create directory at 'XXXX': Permission denied

解决此问题最好的方法是什么?我需要将 git 用户无密码sudo权限授予 su 作为节点用户?或者这可以通过更改组和文件夹权限来修复?还是完全不同的方法?我失去了!

What's the best way to resolve this? Do I need to grant the git user password-less sudo rights to su as the node user? Or can this be somehow fixed by changing groups and folder permissions? Or a different approach entirely? I'm lost!

谢谢!

推荐答案

当然,您可以在后接收中有一个例子钩子权限被拒绝无法创建文件错误,将git命令包装在脚本中。

Using sudo would certainly work, you have one example at "post-receive hook permission denied "unable to create file" error", wrapping the git commands in a script.


更改后接收到:

Changed post-receive to:



sudo sh /usr/local/sbin/prgetsimpleappscom




更改sudoers with visudo

Changed sudoers with visudo



git ALL = (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom

另一种方法将是一个cron作业,作为节点用户定期提取,(如果有新提交)拉在目的地回购。

The other approach would be a cron job as node user regularly fetching and (if there are new commit) pulling in the destination repo.

这篇关于通过Gitolite部署节点应用程序和后接收挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆