简体   繁体   English

从Hudson运行时,Tomcat脚本不起作用

[英]Tomcat script not working when run from Hudson

I'm trying to run a script which stops and starts Tomcat on linux. 我正在尝试运行一个脚本,该脚本在Linux上停止并启动Tomcat。

When I run it from the command line it works fine. 当我从命令行运行它时,它工作正常。 But it does not seem to work when I run the same script from the "Execute Shell" build step in a Jenkins/Hudson job. 但是,当我在Jenkins / Hudson作业的“ Execute Shell”构建步骤中运行相同的脚本时,它似乎不起作用。 Jenkins doesn't report any errors but if I try going to the tomcat page then I get a page not found error. 詹金斯(Jenkins)没有报告任何错误,但是,如果我尝试进入tomcat页面,则会收到页面未找到错误。

So Jenkins seems able to stop the server, but not bringing it back up. 因此,詹金斯(Jenkins)似乎能够停止服务器,但无法将其恢复。

I'd be grateful for any help. 我将不胜感激。

Try unsetting the BUILD_ID in your 'shell execute' block. 尝试在“ shell执行”块中取消设置BUILD_ID。 You might even not need to use nohup in this case 在这种情况下,您甚至可能不需要使用nohup

BUILD_ID=
./your_hudson_script_that_starts_tomcat.sh

Without seeing your script it is difficult to give an exact answer. 没有看到您的脚本,很难给出确切的答案。 However you could try adding the following to the start of your script (assuming it is a bash script): 但是,您可以尝试将以下内容添加到脚本的开头(假设它是bash脚本):

# Trace executed commands.
set -x

# Save stdout / stderr in files
exec >/tmp/my_script.stdout
exec 2>/tmp/my_script.stderr

You could also try adding 您也可以尝试添加

set -e

to make the shell exit immediately if a command returns an error status. 如果命令返回错误状态,将使外壳立即退出。

If it looks as though Hudson is killing off Tomcat then you might want to run it within nohup (if you're not already doing that): 如果看起来哈德森正在杀死Tomcat,那么您可能希望在nohup中运行它(如果您尚未这样做):

nohup bin/startup.sh >/dev/null 2>&1 &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM