Skip to content

Need cockpit.spawn() to wait till the command (bash script with a couple of arguments) provided completes its execution entirely #19606

Closed Answered by martinpitt
sjagtap asked this question in Q&A
Discussion options

You must be logged in to vote

What I could understand from the above was that the script will run in the background and the createVmDialog.jsx code will continue to execute while the script finishes execution

No, this isn't what happens. cockpit.spawn().then(() => console.log("done")), or alternatively, await cockpit.spawn() really does wait until the process finishes. You can save the result of spawn into a variable, and add some console.log() messages to follow when it finishes or catches.

Two theories: (1) you don't await the call of doReplicaOfImage()? (2) Your manage_image.sh script is failing early? I suggest adding set -x and writing it to the console.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sjagtap
Comment options

Answer selected by sjagtap
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants