我有一个运行gradle build这样的脚本......
$HOME_DIR$CODE_DIR/gradlew -p $HOME_DIR$CODE_DIR build
Run Code Online (Sandbox Code Playgroud)
当我定期运行./start.local.sh它时,它工作正常。但是当我尝试像nohup ./start.local.sh &我一样使用 nohup 时......
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
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
尝试定义一个输入流描述符,这个魔法对我有用:
nohup ./start.local.sh > build.log 2>&1 < /dev/null &
Run Code Online (Sandbox Code Playgroud)
这是https://issues.gradle.org/browse/GRADLE-3535 中描述的已知 Gradle 错误。Gradle 期望输入(stdin)和输出流(stdout 和 stderr)。当您使用 nohup 命令时,没有标准输入和标准输出/错误,如果应用程序有严格的要求,您应该定义它们:
2>&1 - redirect for stderr to stdout,
> build.log - redirect stdout to log file,
< /dev/null - use /dev/null as input stream
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2328 次 |
| 最近记录: |