Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing functionality - how to run command in background #22

Open
robooo opened this issue Apr 19, 2024 · 3 comments
Open

Missing functionality - how to run command in background #22

robooo opened this issue Apr 19, 2024 · 3 comments

Comments

@robooo
Copy link

robooo commented Apr 19, 2024

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?

@pablochacin
Copy link
Contributor

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)

@robooo
Copy link
Author

robooo commented Jun 2, 2024

@pablochacin sorry I wrote like 0 lines in golang but found this:
https://github.com/takama/daemon
maybe this can be integrated?

@pablochacin
Copy link
Contributor

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants