diff --git a/tutorials/file_sharing_app/Dockerfile b/tutorials/file_sharing_app/Dockerfile index 0f7c99feb..28e49e8d4 100644 --- a/tutorials/file_sharing_app/Dockerfile +++ b/tutorials/file_sharing_app/Dockerfile @@ -11,8 +11,8 @@ COPY . . # Build the Rust crate RUN cargo build --release -# Run the first node -CMD ["cargo", "run", "--release", "--features=first-node"] +# Run the script to start both nodes +COPY run_both_nodes.sh . +RUN chmod +x run_both_nodes.sh -# Run the second node after the first one completes -CMD ["cargo", "run", "--release", "--features=second-node"] \ No newline at end of file +CMD ["./run_both_nodes.sh"] \ No newline at end of file diff --git a/tutorials/file_sharing_app/README.md b/tutorials/file_sharing_app/README.md index 9996c084c..3e515969d 100644 --- a/tutorials/file_sharing_app/README.md +++ b/tutorials/file_sharing_app/README.md @@ -10,6 +10,8 @@ A 5 second timeout is set to give enough time for the nodes to communicate with > This example uses `async-std-runtime` specified in the crate's Cargo.toml file to demonsrate SwarmNl's compatibility with using the async-std runtime. +**Note:** The example requires a quorum of 1, which means that that if the second node does not run the first node will not be able to write to the DHT and will panic. + ## Run the example To run this example, you'll need two terminals. @@ -94,4 +96,4 @@ Run: ```bash docker run -it file-sharing-demo -``` \ No newline at end of file +``` diff --git a/tutorials/file_sharing_app/run_both_nodes.sh b/tutorials/file_sharing_app/run_both_nodes.sh new file mode 100644 index 000000000..f236dbd4a --- /dev/null +++ b/tutorials/file_sharing_app/run_both_nodes.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Used for the Docker container to run both nodes + +# Run the first command in the background +cargo run --features=first-node & + +# Run the second command in the foreground +cargo run --features=second-node \ No newline at end of file