I have a script that runs a gradle build
like this...
$HOME_DIR$CODE_DIR/gradlew -p $HOME_DIR$CODE_DIR build
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
What am I missing?
Try to define an input stream descriptor, this magic works for me:
nohup ./start.local.sh > build.log 2>&1 < /dev/null &
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With