尝试运行Gradle Build时获取DisconnectableInputStream源阅读器 [英] Getting DisconnectableInputStream source reader while trying to run Gradle Build
问题描述
我有一个脚本,可以像这样运行 gradle build
...
I have a script that runs a gradle build
like this...
$HOME_DIR$CODE_DIR/gradlew -p $HOME_DIR$CODE_DIR build
当我像 ./start.local.sh
这样定期运行此程序时,它可以正常工作.但是当我尝试像 nohup ./start.local.sh&
这样使用nohup时,我得到...
When I run this regularly like ./start.local.sh
it works fine. But when I try to use nohup like nohup ./start.local.sh &
I get...
Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.io.IOException: Bad file descriptor
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
at org.gradle.util.DisconnectableInputStream$1.run(DisconnectableInputStream.java:125)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.io.IOException: Bad file descriptor
我想念什么?
推荐答案
尝试定义输入流描述符,这种魔术对我有效:
Try to define an input stream descriptor, this magic works for me:
nohup ./start.local.sh > build.log 2>&1 < /dev/null &
这是 https://issues.gradle.org/browse/中描述的已知Gradle错误.GRADLE-3535 .对输入(stdin)和输出流(stdout和stderr)的Gradle期望.使用nohup命令时,没有stdin和stdout/err,如果应用程序有严格的要求,则应定义它们:
This is a known Gradle bug described in https://issues.gradle.org/browse/GRADLE-3535. Gradle expect for input (stdin) and output streams(stdout and stderr). When you use nohup command there is no stdin and stdout/err and you should define them if application have a tight requirements:
2>&1 - redirect for stderr to stdout,
> build.log - redirect stdout to log file,
< /dev/null - use /dev/null as input stream
这篇关于尝试运行Gradle Build时获取DisconnectableInputStream源阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!