xk6-exec
xk6-exec copied to clipboard
Missing functionality - how to run command in background
I needed to run command (binary) in the background which will run during the k6 execution and found that (probably because of exec.Command
) it will wait forever if I run it like:
console.log(exec.command("mycmd", ["&"]));
I found one way which is working for me as a workaround:
console.log(exec.command("bash", ["-c", "setsid mycmd >/dev/null 2>&1 < /dev/null &"]));
but this way I'm loosing all logs or info about the activity.
Does it make sense to include handling of background task functionality into this library?
Does it make sense to include handling of background task functionality into this library?
@robooo Do you have a proposal for the API? I'm not sure how we could expose the output from this background process, or detect its finalization (or force the finalization when the test ends)
@pablochacin sorry I wrote like 0 lines in golang but found this: https://github.com/takama/daemon maybe this can be integrated?
@robooo this daemon package is interesting, thanks for sharing. However I'm still unsure about how to integrate running a background process in the exec API:
I'm not sure how we could expose the output from this background process, or detect its finalization (or force the finalization when the test ends)