Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting DisconnectableInputStream source reader while trying to run Gradle Build

Tags:

gradle

nohup

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?

like image 805
Jackie Avatar asked Jun 05 '18 17:06

Jackie


1 Answers

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
like image 150
Vitos Avatar answered Sep 21 '22 07:09

Vitos