Starting multichain and creating streams from script

+1 vote

I am trying to automate a creation of a multichain and also create/subscribe to a stream. 

I wrote a bash script to run inside a docker container and the main elements of it are;

multichaind -txindex -printtoconsole -shrinkdebugfilesize $CHAINNAME

multichain-cli $CHAINNAME create stream test false
multichain-cli $CHAINNAME create stream user_data false
multichain-cli $CHAINNAME subscribe test
multichain-cli $CHAINNAME subscribe user_data

I pretty much copied it from here - https://github.com/Kunstmaan/docker-multichain/blob/master/master/runchain.sh

My problem is, once the multichain starts it doesn't go on to create the streams. I tried adding -daemon at the end of the start command but then the docker container just stops once it gets to the bottom of the script.

Any ideas how I can start up the multichain but also run the create stream commands, all being executed from a bash file

asked Aug 31 by doldy101

1 Answer

+1 vote

To begin with, you definitely need -daemon, otherwise the shell script will be stuck waiting for multichaind to finish running before it moves on to the next step.

As for why the Docker container stops at the end of the script, I guess you'll need to find some option in Docker to prevent it doing that, for as long as one of the spawned processes is still running.

Or perhaps you can add the fg command to bring multichaind back to the front, after the streams are created.

answered Aug 31 by MultiChain
ok thanks for confirming that I need to include the -daemon flag when starting multichain. I will try your suggestions on getting the docker container to stay running
...