Pārlūkot izejas kodu

Create a two-pi-plus-dev setup for durio.

1. Three IPs are hard coded, one for the dev machine and two for Pis.
2. The two Pis must be connected to the same network as the dev
machine.
3. A script (build.sh) is added to cross build to an ARM binary.
4. A script (curl.sh) is added to test the services.
Jing Yang 4 gadi atpakaļ
vecāks
revīzija
f3059b79ff
3 mainītis faili ar 42 papildinājumiem un 6 dzēšanām
  1. 26 0
      durio/build.sh
  2. 6 0
      durio/curl.sh
  3. 10 6
      durio/src/main.rs

+ 26 - 0
durio/build.sh

@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# To setup cross build on a linux machine, do the following
+# 1. Install package arm-linux-gnu-gcc (yum) or gcc-arm-linux-gnueabihf (apt).
+# 2. Run `rustup target add armv7-unknown-linux-musleabihf`
+# 1. Add the following to ~/.cargo/config
+# [target.armv7-unknown-linux-musleabihf]
+# linker = "arm-linux-gnu-gcc"
+
+set -ex
+rsync -av /Users/ditsing/Code/ruaft ec2:~/compile/ --exclude 'ruaft/target' --exclude 'ruaft/.git' --exclude '.idea'
+ssh ec2 'cd ~/compile/ruaft/durio && cargo build --target=armv7-unknown-linux-musleabihf --release'
+mkdir -p /tmp/ruaft
+rsync -av 'ec2:~/compile/ruaft/target/armv7-unknown-linux-musleabihf/release/durio' '/tmp/ruaft/durio'
+
+ssh alice 'pkill -9 durio || echo nothing'
+rsync -av '/tmp/ruaft/durio' alice:/tmp/durio
+ssh alice '
+  RUST_LOG=warp,tarpc=error,ruaft=debug,kvraft=debug,durio nohup /tmp/durio 1 1>>/tmp/durio.out 2>>/tmp/durio.err &
+'
+
+ssh bob 'pkill -9 durio || echo nothing'
+rsync -av '/tmp/ruaft/durio' bob:/tmp/durio
+ssh bob '
+  RUST_LOG=warp,tarpc=error,ruaft=debug,kvraft=debug,durio nohup /tmp/durio 2 1>>/tmp/durio.out 2>>/tmp/durio.err &
+'
+RUST_LOG=warp,tarpc=error,ruaft=debug,kvraft=debug,durio cargo run 0

+ 6 - 0
durio/curl.sh

@@ -0,0 +1,6 @@
+curl -i -X POST -H 'Content-Type: application/json' -d '{"key": "hi", "value": "Hello "}' http://10.1.1.51:9007/kvstore/put
+curl -i -X GET http://10.1.1.56:9008/kvstore/get/hi
+curl -i -X POST -H 'Content-Type: application/json' -d '{"key": "hi", "value": "World!"}' http://10.1.1.198:9006/kvstore/append
+curl -i -X GET http://10.1.1.51:9007/kvstore/get/hi
+curl -i -X POST -H 'Content-Type: application/json' -d '{"key": "hi", "value": "      "}' http://10.1.1.56:9008/kvstore/put
+curl -i -X GET http://10.1.1.198:9006/kvstore/get/hi

+ 10 - 6
durio/src/main.rs

@@ -22,16 +22,20 @@ struct PutAppendBody {
     value: String,
 }
 
+const IP_ONE: [u8; 4] = [10, 1, 1, 198];
+const IP_TWO: [u8; 4] = [10, 1, 1, 51];
+const IP_THREE: [u8; 4] = [10, 1, 1, 56];
+
 lazy_static! {
     static ref KV_ADDRS: Vec<SocketAddr> = vec![
-        ([127, 0, 0, 1], 9986).into(),
-        ([127, 0, 0, 1], 9987).into(),
-        ([127, 0, 0, 1], 9988).into(),
+        (IP_ONE, 9986).into(),
+        (IP_TWO, 9987).into(),
+        (IP_THREE, 9988).into(),
     ];
     static ref RAFT_ADDRS: Vec<SocketAddr> = vec![
-        ([127, 0, 0, 1], 10006).into(),
-        ([127, 0, 0, 1], 10007).into(),
-        ([127, 0, 0, 1], 10008).into(),
+        (IP_ONE, 10006).into(),
+        (IP_TWO, 10007).into(),
+        (IP_THREE, 10008).into(),
     ];
     static ref WEB_ADDRS: Vec<SocketAddr> = vec![
         ([0, 0, 0, 0], 9006).into(),