spring-batch
spring-batch copied to clipboard
Add log management to SystemCommandTasklet [BATCH-2329]
Michael Minella opened BATCH-2329 and commented
Currently there is no way to get the output of a command run via a SystemCommandTasklet. This will add the ability to either store the log output in the ExecutionContext or direct it to a file. This functionality should be similar to what Spring XD did in their AbstractProcessBuilderTasklet.
Issue Links:
-
XD-2519 Refactor Spark and Sqoop tasklets to use SystemCommandTasklet ("is depended on by")
-
BATCH-2133 How about showing result of command itself in SystemCommandTasklet?
-
BATCH-2318 Add option to consume error and input streams to SystemCommandTasklet
Glenn Lingle commented
A comment about SystemCommandTasklet and reading from Process stderr/stdout. If used with processes which output more than a buffer-full (nebulous term - size varies), it will hang if you use the approach of AbstractProcessBuilderTasklet : reading the output after the process is finished.
Note that if you are redirecting to a file, there is no problem, no hangs. It is only a problem if you are reading from stderr/stdout.
We were using the SystemCommandTasklet when we first started using SB, but made our own when we started getting hangs. We initially started using the same approach of AbstractProcessBuilderTasklet of pulling stderr/stdout to log after process finished - still hung if output was any significant size.
More investigation revealed this excellent article which talks about the proper way of reading Process stderr/stdout: http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html We use this approach and it works well.
HTH, Glenn