2021-02-25 21:18:07 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-06-13 20:54:37 +00:00
|
|
|
set -o errexit -o nounset -o pipefail
|
2021-02-25 21:18:07 +00:00
|
|
|
|
2021-06-13 20:54:37 +00:00
|
|
|
if [[ -z "${NODE:-}" ]]; then
|
|
|
|
NODE_ADDR=""
|
|
|
|
else
|
|
|
|
NODE_ADDR="--node-addr $NODE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check `marine` and `fldist` tools are installed or install them
|
2021-06-13 20:26:30 +00:00
|
|
|
(command -v marine || cargo install marine) >/dev/null
|
2021-02-25 21:18:07 +00:00
|
|
|
(command -v fldist || npm install -g @fluencelabs/fldist) >/dev/null
|
|
|
|
|
|
|
|
# build .wasm
|
|
|
|
(
|
|
|
|
cd backend
|
2021-06-13 20:26:30 +00:00
|
|
|
marine build --release
|
2021-02-25 21:18:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# check it .wasm was built
|
|
|
|
WASM="backend/target/wasm32-wasi/release/curl_template.wasm"
|
|
|
|
test -f "$WASM" || echo >&2 "Couldn't find $WASM"
|
|
|
|
|
|
|
|
# create a service from that .wasm
|
|
|
|
CONFIG="$(pwd)/backend/BackendConfig.json"
|
2021-06-13 20:54:37 +00:00
|
|
|
SERVICE_ID=$(fldist new_service $NODE_ADDR --modules "$WASM:$CONFIG" --name call_parameters | head -n1 | sed -e 's/service id: //')
|
|
|
|
echo $SERVICE_ID
|