使用Jenkins成功部署后,重新启动Tomcat [英] Restarting Tomcat after a successful deployment with Jenkins

查看:555
本文介绍了使用Jenkins成功部署后,重新启动Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

成功部署后,如何让Jenkins重新启动Tomcat实例?

How can I have Jenkins restart a Tomcat instance after a successful deployment?

我已经尝试使用批处理脚本,但是在构建完成后,Tomcat实例被杀死.

I already tried using a batch script, but the Tomcat instance is killed when the build is finished.

推荐答案

您的答案位于 Jenkins ProcessTreeKiller . 此处更详细的解释 .

Your answer lies in Jenkins ProcessTreeKiller. A more detailed explanation here.

这是一项设计决策,要求杀死由构建产生的任何进程以保持干净的环境.不幸的是,这意味着您不能在构建后让进程(例如Tomcat)运行.

It's a design decision to kill any processes that are spawned by the build to maintain a clean environment. Unfortunately that means you can't leave a process (such as Tomcat) running after the build.

您可以像下面这样启动Jenkins,以全局禁用此功能(不建议使用):
java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war

You can disable this functionality globally (not recommended) by launching Jenkins like this:
java -Dhudson.util.ProcessTree.disable=true -jar jenkins.war

或者您可以通过更改环境变量启动进程来逐个禁用此功能:
BUILD_ID=dontKillMe ./catalina restart

Or you can disable this on a per-case basis, by launching the process with a changed environment variable:
BUILD_ID=dontKillMe ./catalina restart

但是有些人报告说仅更改BUILD_ID是不够的.他们还建议取消设置:
JENKINS_COOKIE
JENKINS_SERVER_COOKIE

Some people report however that changing BUILD_ID is not enough. They recommend also unsetting:
JENKINS_COOKIE
JENKINS_SERVER_COOKIE


另一个可能的问题是,当您连接到远程Shell并在该远程Shell会话中启动进程时,(詹金斯)断开连接后,该会话将被杀死,并且该会话产生的所有进程也将被杀死.要解决该问题,您需要取消该进程与Shell会话的关联.


Another issue that could be at play is that when you connect to remote shell, and start a process in that remote shell session, once you (Jenkins) disconnects, the session is killed and all processes spawned by the session are killed too. To get around that issue, you need to disassociate the process from the shell session.

一种方法是:

nohup ./catalina restart &

这篇关于使用Jenkins成功部署后,重新启动Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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