process java 脚本,如何调用shell脚本来启动后端Java进程?

After completing a Jenkins task, I execute a Linux shell script by using Jenkins' post-condition configuration section.

This Linux shell script wants to launch a standby service on the backend and can NOT cause Jenkins to pause.

I tried to use "nohup+&", etc., but it does not work.

Is there a good way to do it?

解决方案

Jenkins is probably waiting for some pipes to close. Your background process has inherited some file descriptors and is keeping them open for as long as it runs.

If you are lucky, the only file descriptors are 0, 1 and 2 (the standard ones.) You might want to check the file descriptors of the background process using lsof -p PID where PID is the process id of the background process.

You should make sure all of those file descriptors (both inputs and outputs) are redirected for the background process, so start it with something like:

nohup daemon /dev/null 2>&1 &

Feel free to direct the output to a file other than /dev/null but make sure you keep the order of the redirections. The order is important.

If you plan to start background processes from a Jenkins job, be advised that Jenkins will kill background processes when build ends. See https://wiki.jenkins-ci.org/display/JENKINS/ProcessTreeKiller on how to prevent that.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值