SBT 挂起等待孤立子进程完成 [英] SBT hangs waiting for orphaned subprocess to complete

查看:35
本文介绍了SBT 挂起等待孤立子进程完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 SBT (0.13.16) 版本中,我有以下任务:

In my SBT (0.13.16) build, I have the following task:

startThing := {
  var bin_path = s"${file(".").getAbsolutePath}/bin"
  val result = s"$bin_path/start_thing".!
  if (result != 0)
    throw new RuntimeException("Could not start Thing..")
  true
}

并且 start_thing 包含:

(run_subprocess &)

我的构建挂起.

我可以看到 start_thing 退出(进程表没有将其作为条目)但是向任务添加一些 println 显示它卡在 val 结果 = s"$bin_path/start_thing".!.

I can see that start_thing exits (the process table does not have it as an entry) but adding some printlns to the task shows that it's stuck on val result = s"$bin_path/start_thing".!.

如果我终止 run_subprocess 进程,那么 SBT 会解除阻塞并正常运行.

If I kill the run_subprocess process then SBT unblocks and runs normally.

在这种特殊情况下,run_subprocess 已经设置了一些 Kubernetes 端口转发,需要在那里进行后续测试才能正常工作.

In this particular case, run_subprocess has set up some Kubernetes port-forwarding that needs to be there in order for subsequent tests to work.

推荐答案

尝试 daemonising 后台进程像这样

Try daemonising the background process like so

(run_subprocess >/dev/null 2>&1 &)

该问题可能是 run_subprocess 的输出,仍然按照建议的 sbt parent 此处.

The issue could be output from run_subprocess still going to sbt parent as suggested here.

我能够在 sbt 0.13.17 和 1.0.2 中复制该问题.守护进程在两者中都有效.

I was able to replicate the issue in both sbt 0.13.17 and 1.0.2. Daemonising worked in both.

这篇关于SBT 挂起等待孤立子进程完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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