问题描述
我目前使用Phing和詹金斯自动构建和部署我的codeIgniter应用程序。我在与正在重新启动Apache服务麻烦的一个问题。我试着在Phing,但没有足够的权限。什么是重新启动的最佳方式?
编辑:
詹金斯加入到sudoer文件,并exec'ing服务的httpd重新启动后,詹金斯抛出:过程泄漏文件描述符。以下是通过詹金斯的Phing输出的一个片段。它说,一个解决办法是安装以进程。不知道这意味着什么...
... Build_test> COM preSS: [回应] YUI的COM pression开始
[回应]以com pressed文件替换正常的JS。
[回应]以com pressed文件替换正常的CSS。
[回应] chmoding资产
[回应] YUI的COM pression结束Build_test> pdepend:
Build_test> httpd_restart: [回应]停止的httpd:[确定]
[回音]开始的httpd:[确定]
BUILD FINISHED总时间:13.1424秒流程泄露文件描述符。见http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build了解更多信息
[JDepend] JDepend插件就绪
[JDepend]发现有68类1包
成品:成功
如果你是在Linux上,你可以使用sudo命令允许它足够的权限重新启动Apache运行Phing。
须藤phing restartapache
假设restartapache是Exec任务调用Apache的重新启动命令。例如:
<目标名称=restartapache描述=重新启动Web服务器>
< exec命令=/等/ init.d /的的Apache2重启/>
< /目标与GT;
要避免sudo命令提示输入密码,您可以更新任何用户帐户你是下运行您的构建(这个例子说明关闭sudo的密码提示输入用户詹金斯)你的sudo权限:
须藤visudo命令
然后加上下面几行:
默认值:!詹金斯requiretty,讲座
詹金斯ALL = NOPASSWD:/etc/init.d/apache2
上面的已被编辑根据提高安全性this回答让詹金斯只允许重新启动Apache没有密码,别无其他。
I'm currently using Phing and Jenkins to automate builds and deployment for my CodeIgniter app. One problem I'm having trouble with is restarting the apache service. I tried in Phing but there isn't enough permissions. What is the best way to restart?
EDIT:
After adding jenkins into the sudoer file and exec'ing the service httpd restart, Jenkins throws: Process leaked file descriptors. Below is a snippet of the Phing output via Jenkins. It says a workaround is to install daemonize. Not sure what that means...
...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
If you're on Linux you can run Phing with the sudo command to allow it enough privileges to restart apache.
sudo phing restartapache
Assuming that restartapache is an exec task that calls the apache restart command. Eg:
<target name="restartapache" description="Restarts the web server">
<exec command="/etc/init.d/apache2 restart" />
</target>
To avoid the sudo command prompting for a password you can update your sudo permissions for whatever user account you are running your build under (this example demonstrates turning off the sudo password prompt for the jenkins user):
sudo visudo
Then add the following lines:
Defaults:jenkins !requiretty,!lecture
jenkins ALL=NOPASSWD:/etc/init.d/apache2
The above has been edited to improve security according to this answer so that Jenkins is only allowed to restart apache without a password and nothing else.
这篇关于与詹金斯或Phing重启动Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!