Hudson-CI 启动的屏幕会话在任务结束时终止

发布于 2024-10-21 01:01:49 字数 652 浏览 4 评论 0原文

我遇到的主要问题是从 Hudson-CI 进行屏幕会话的后台处理。 shell 步骤是我需要从另一个脚本启动的脚本启动屏幕会话。这是一个简单的测试:

test.sh:

#!/bin/bash
myscreen.sh

myscreen.sh:

#!/bin/bash
screen -dm -S myscreen pingit.sh

pingit.sh:

#!/bin/bash
ping google.com

如果我运行 ./myscreen.sh 我会启动一个屏幕,连续运行 ping 没有问题。

如果我运行 ./test.sh,屏幕永远不会启动。我假设有一些基本的东西我忘记了或不理解,但我不知道是什么。我认为这会起作用。

我想要这样做的真正原因是让 Hudson CI 启动一个连续测试脚本,该脚本作为屏幕会话启动,以便它可以在后台继续。我发现,一旦 Hudson 中的任务完成,屏幕会话就会终止。

关于为什么我无法从祖父母脚本启动持久屏幕会话有什么想法吗?或者关于如何处理这个问题有什么想法吗?

这是在 OSX 10.6 上,屏幕是从源代码构建的(所以我认为它应该与 Linux 一样工作)。

The main problem I'm having is to background a screen session from Hudson-CI. The shell steps are that I need to start a screen session from a script that is launched by another script. Heres' a simple test:

test.sh:

#!/bin/bash
myscreen.sh

myscreen.sh:

#!/bin/bash
screen -dm -S myscreen pingit.sh

pingit.sh:

#!/bin/bash
ping google.com

If I run ./myscreen.sh I get a screen launched that runs the ping continuously without a problem.

If I run ./test.sh, the screen is never started. I'm assuming there's something basic that I'm either forgetting or not understanding, but I can't figure out what. I thought this would work.

The real reason I want to do this is to have Hudson CI launch a continuous-test script which starts as a screen session so that it can continue in the background. What I'm finding is that the screen session terminates once the task is completed in Hudson.

Any ideas on why I can't launch a persistent screen session from a grand-parent script? Or any ideas on how to deal with this?

This is on OSX 10.6, with screen built from source (so it should work the same as linux I think).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筱果果 2024-10-28 01:01:49

如果我运行您的 test.sh,我会收到错误消息

./test.sh: Zeile 2: myscreen.sh: Kommando nicht gefunden.

,即找不到命令。如果当前目录不在路径上,则必须编写 ./myscreen.sh。 (适合你吗?不应该。)这对于屏幕调用同样有效。

将这两个文件更改为

#!/bin/bash
./myscreen.sh

#!/bin/bash
screen -dm -S myscreen ./pingit.sh

我就可以毫无问题地启动屏幕。

我在

$ screen --version
Screen version 4.00.03 (FAU) 23-Oct-06

这里使用 Linux (OpenSUSE)。

If I run your test.sh, I get the error message

./test.sh: Zeile 2: myscreen.sh: Kommando nicht gefunden.

i.e. command not found. You'll have to write ./myscreen.sh, if the current directory is not on the path. (Is it for you? It should not.) The same is valid for the screen call.

Changing both files to

#!/bin/bash
./myscreen.sh

and

#!/bin/bash
screen -dm -S myscreen ./pingit.sh

I can start my screen without any problems.

I'm on Linux (OpenSUSE) with

$ screen --version
Screen version 4.00.03 (FAU) 23-Oct-06

here.

十年不长 2024-10-28 01:01:49

我不知道为什么我之前没有找到以下参考资料,但这些是帮助我解决问题的链接:

这里有 2 个问题 - 一屏幕在由祖父母进程启动后被持久化。另一个是 hudson 在完成任务后终止会话。

屏幕问题是通过僵尸化进程来解决的,如下所示:

screen -d -m -S myscreen && screen -S myscreen -X zombie qr && screen -S myscreen -X screen pingit.sh

Hudson-CI 问题结果是一个错误,可以通过上面的链接轻松解决。解决方案是在 shell 脚本中添加 BUILD_ID=something 。因此,如果上面的 test.sh 脚本实际上是 Hudson Build shell 执行的,那么它必须更改为:

#!/bin/bash
BUILD_ID=dontkillthisprocess
myscreen.sh

一旦实现了这两个步骤,一切就正常了。

I don't know why I did not find the following references before, but these were the links that helped me solve the problem:

There are 2 issues here - one of screen being persisted after being launched by a grand-parent process. The other that hudson terminates a session after it completes its task.

The screen problem is resolved by zombie'ing the process as follows:

screen -d -m -S myscreen && screen -S myscreen -X zombie qr && screen -S myscreen -X screen pingit.sh

The Hudson-CI problem turns out to be a bug that's easily resolved per the above link. The solution is to add BUILD_ID=something into the shell script. So if the test.sh script from above is actually the Hudson Build shell execute, then it would have to be changed to:

#!/bin/bash
BUILD_ID=dontkillthisprocess
myscreen.sh

Once both of these steps are implemented, things work fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文