我目前正在使用Phing和Jenkins来自动化我的CodeIgniter应用程序的构建和部署。我遇到的一个问题是重新启动apache服务。我试过Phing,但是没有足够的权限。重新启动的最佳方式是什么?
编辑:
在将jenkins添加到sudoer文件并执行服务httpd重新启动之后,Jenkins抛出: Process泄漏的文件描述符。下面是通过Jenkins的Phing输出的片段。它说解决办法是安装守护进程。不知道那是什么意思..。
...Build_test > compress:
[echo] YUI Compression started
[echo] Replacing normal JS with compressed files.
[echo] Replacing normal CSS with compressed files.
[echo] chmoding assets
[echo] YUI Compression ended
Build_test > pdepend:
Build_test > httpd_restart:
[echo] Stopping httpd: [ OK ]
[echo] Starting httpd: [ OK ]
BUILD FINISHED
Total time: 13.1424 seconds
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
[JDepend] JDepend plugin is ready
[JDepend] Found 68 classes in 1 packages
Finished: SUCCESS发布于 2011-08-01 10:50:33
如果您在Linux上,您可以使用sudo命令运行Phing,从而允许它获得足够的特权来重新启动apache。
sudo phing restartapache假设restartapache是一个调用apache命令的exec任务。例:
<target name="restartapache" description="Restarts the web server">
<exec command="/etc/init.d/apache2 restart" />
</target> 为了避免sudo命令提示输入密码,您可以为运行构建的任何用户帐户更新sudo权限(本例演示关闭jenkins用户的sudo密码提示):
sudo visudo然后添加以下行:
Defaults:jenkins !requiretty,!lecture
jenkins ALL=NOPASSWD:/etc/init.d/apache2根据this answer,对上面的内容进行了编辑,以提高安全性,因此Jenkins只允许在没有密码的情况下重新启动apache。
https://stackoverflow.com/questions/6896644
复制相似问题