通过Jenkins SSH Shell脚本在远程服务器上启动守护程序神秘退出 [英] start daemon on remote server via Jenkins SSH shell script exits mysteriously

查看:611
本文介绍了通过Jenkins SSH Shell脚本在远程服务器上启动守护程序神秘退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jenkins上有一个正在构建我的项目的构建作业,完成后,它将在远程服务器上打开ssh shell脚本并传输文件,然后停止并启动守护程序.

I have a build job on jenkins that is building my project and after it is done, it opens an ssh shell script on a remote server and transfers files and then stop and starts a daemon.

当我从RHEL服务器上的命令行停止并启动守护程序时,它执行得很好.以詹金斯执行作业时,没有错误.

When I stop and start the daemon from the command line on a RHEL server, it executes just fine. When the job executes in jenkins, there are no errors.

守护程序可以正常停止并且可以正常启动.但是启动后不久,守护进程突然死亡.

The daemon stops fine and it starts fine. But shortly after starting, the daemon dies suddenly.

sudo service daemonName stop
# transfer files.
sudo service daemonName start

我确定问题出在哪里

有人知道Jenkins执行ssh shell脚本的方式有什么特殊之处,它会导致守护进程启动未完全完成吗?

Does anyone know what could be special about the way Jenkins is executing the ssh shell script that would cause the daemon start to not fully complete?

推荐答案

问题: 通过jenkins执行构建时,启动守护进程的命令显然已成功执行,但是在构建作业完成后,守护进程会突然退出.

The problem: When executing a build through jenkins, the command to start the daemon process was clearly successfully executing, yet after the build job was done, the daemon would suddenly quit.

解决方案: 我一直以来都以为詹金斯杀死了守护进程.因此,我尝试了禁用通过并清除僵尸子进程的ProcessTree模块的许多不同形式和置换.我尝试通过重置BUILD_ID环境变量来愚弄它.什么都没用.

The solution: I thought for this whole time that it was jenkins killing the daemon. So I tried many different incarnations and permutations of disabling the ProcessTree module that goes through and cleans up zombie child processes. I tried fooling it by resetting the BUILD_ID environment variable. Nothing worked.

由于有了这个线程,我发现该解决方案仅适用于在BUILD机器上执行的子进程. IE.不适用于我的问题.

Thanks to this thread I found out that that solution only works for child processes executed on the BUILD machine. I.E. not applicable to my problem.

更多搜索将我引到了这里:通过ssh运行持久性进程

More searching led me here: Run a persistent process via ssh

解决方案?没事.

因此,现在构建通过执行以下操作成功重启守护程序: sudo nohup服务守护程序名称启动

So now the build successfully restarts the daemon by executing the following: sudo nohup service daemonname start

这篇关于通过Jenkins SSH Shell脚本在远程服务器上启动守护程序神秘退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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