From 09b79083b23921167168c8ccf2b22019dfbc33b8 Mon Sep 17 00:00:00 2001 From: "Zheng, Qi" Date: Sun, 26 Sep 2021 11:04:59 +0800 Subject: [PATCH] Update redis demo with copy_bom tool Signed-off-by: Zheng, Qi --- demos/redis/benchmark.sh | 2 +- demos/redis/download_and_build_redis.sh | 2 +- demos/redis/redis.yaml | 9 +++++++++ demos/redis/redis_glibc.yaml | 9 +++++++++ demos/redis/run_occlum_redis.sh | 11 ++++++----- demos/redis/run_occlum_redis_glibc.sh | 16 ++++++---------- 6 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 demos/redis/redis.yaml create mode 100644 demos/redis/redis_glibc.yaml diff --git a/demos/redis/benchmark.sh b/demos/redis/benchmark.sh index e28cb17a..b053fecf 100755 --- a/demos/redis/benchmark.sh +++ b/demos/redis/benchmark.sh @@ -1,4 +1,4 @@ ./run_occlum_redis.sh & sleep 20 echo 'start client' -/usr/local/occlum/x86_64-linux-musl/bin/redis-benchmark -n 1000 +/usr/local/occlum/x86_64-linux-musl/redis/bin/redis-benchmark -n 1000 diff --git a/demos/redis/download_and_build_redis.sh b/demos/redis/download_and_build_redis.sh index 31309588..240a0b40 100755 --- a/demos/redis/download_and_build_redis.sh +++ b/demos/redis/download_and_build_redis.sh @@ -28,7 +28,7 @@ build_redis() { export CC=/opt/occlum/toolchains/gcc/bin/occlum-gcc export CXX=/opt/occlum/toolchains/gcc/bin/occlum-g++ make -j `getconf _NPROCESSORS_ONLN` BUILD_TLS=yes - make PREFIX=$PREFIX install + make PREFIX=$PREFIX/redis install popd } diff --git a/demos/redis/redis.yaml b/demos/redis/redis.yaml new file mode 100644 index 00000000..0d5496d6 --- /dev/null +++ b/demos/redis/redis.yaml @@ -0,0 +1,9 @@ +includes: + - base.yaml +# musl redis +targets: + # copy redis + - target: / + copy: + - dirs: + - /usr/local/occlum/x86_64-linux-musl/redis/bin diff --git a/demos/redis/redis_glibc.yaml b/demos/redis/redis_glibc.yaml new file mode 100644 index 00000000..90f14796 --- /dev/null +++ b/demos/redis/redis_glibc.yaml @@ -0,0 +1,9 @@ +includes: + - base.yaml +# glibc redis +targets: + # copy redis + - target: / + copy: + - dirs: + - /usr/local/redis/bin diff --git a/demos/redis/run_occlum_redis.sh b/demos/redis/run_occlum_redis.sh index 474e381f..f8a08ce4 100755 --- a/demos/redis/run_occlum_redis.sh +++ b/demos/redis/run_occlum_redis.sh @@ -1,7 +1,9 @@ #!/bin/bash -occlum_dir=/usr/local/occlum/x86_64-linux-musl set -e +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +bomfile=${SCRIPT_DIR}/redis.yaml + # 1. Init Occlum Workspace rm -rf occlum_instance occlum new occlum_instance @@ -11,10 +13,9 @@ new_json="$(jq '.resource_limits.user_space_size = "320MB" | echo "${new_json}" > Occlum.json # 2. Copy files into Occlum Workspace and Build -cp $occlum_dir/bin/redis* image/bin -cp $occlum_dir/lib/libssl* image/lib -cp $occlum_dir/lib/libcrypto* image/lib -#occlum build +rm -rf image +copy_bom -f $bomfile --root image --include-dir /opt/occlum/etc/template + occlum build # 3. Run redis server occlum run /bin/redis-server --save "" --appendonly no & diff --git a/demos/redis/run_occlum_redis_glibc.sh b/demos/redis/run_occlum_redis_glibc.sh index 331884a3..1d6edce0 100755 --- a/demos/redis/run_occlum_redis_glibc.sh +++ b/demos/redis/run_occlum_redis_glibc.sh @@ -1,8 +1,9 @@ #!/bin/bash -redis_dir=/usr/local/redis/ -occlum_glibc=/opt/occlum/glibc/lib/ set -e +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +bomfile=${SCRIPT_DIR}/redis_glibc.yaml + # 1. Init Occlum Workspace rm -rf occlum_instance occlum new occlum_instance @@ -11,14 +12,9 @@ new_json="$(jq '.resource_limits.user_space_size = "320MB" | .process.default_mmap_size = "256MB"' Occlum.json)" && \ echo "${new_json}" > Occlum.json -# 2. Copy files into Occlum Workspace and Build -cp $redis_dir/bin/redis* image/bin -cp /usr/local/bin/openssl* image/bin -cp /usr/local/lib/libssl* image/$occlum_glibc -cp /usr/local/lib/libcrypto* image/$occlum_glibc -cp $occlum_glibc/libdl.so.2 image/$occlum_glibc -cp $occlum_glibc/librt.so.1 image/$occlum_glibc -cp $occlum_glibc/libm.so.6 image/$occlum_glibc +rm -rf image +copy_bom -f $bomfile --root image --include-dir /opt/occlum/etc/template + #occlum build occlum build # 3. Run redis server