51 lines
1.8 KiB
Bash
Executable File
51 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
BLUE='\033[1;34m'
|
|
NC='\033[0m'
|
|
|
|
check_file_exist() {
|
|
file=$1
|
|
if [ ! -f ${file} ];then
|
|
echo "Error: cannot stat file '${file}'"
|
|
echo "Please see README and build it"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
init_instance() {
|
|
# Init Occlum instance
|
|
rm -rf occlum_instance && occlum new occlum_instance
|
|
cd occlum_instance
|
|
new_json="$(jq '.resource_limits.user_space_size = "1680MB" |
|
|
.resource_limits.kernel_space_heap_size="64MB" |
|
|
.resource_limits.max_num_of_threads = 64 |
|
|
.process.default_heap_size = "256MB" |
|
|
.process.default_mmap_size = "1400MB" |
|
|
.entry_points = [ "/usr/lib/jvm/java-11-alibaba-dragonwell/jre/bin" ] |
|
|
.env.default = [ "LD_LIBRARY_PATH=/usr/lib/jvm/java-11-alibaba-dragonwell/jre/lib/server:/usr/lib/jvm/java-11-alibaba-dragonwell/jre/lib:/usr/lib/jvm/java-11-alibaba-dragonwell/jre/../lib" ]' Occlum.json)" && \
|
|
echo "${new_json}" > Occlum.json
|
|
}
|
|
|
|
build_sofa() {
|
|
# Copy JVM and JAR file into Occlum instance and build
|
|
mkdir -p image/usr/lib/jvm
|
|
cp -r /opt/occlum/toolchains/jvm/java-11-alibaba-dragonwell image/usr/lib/jvm
|
|
cp /usr/local/occlum/x86_64-linux-musl/lib/libz.so.1 image/lib
|
|
mkdir -p image/usr/lib/spring
|
|
cp ../${jar_path} image/usr/lib/spring/
|
|
occlum build
|
|
}
|
|
|
|
run_sofa() {
|
|
jar_path=./sofa-boot-guides/sofaboot-sample-standard/target/boot/sofaboot-sample-standard-web-0.0.1-SNAPSHOT-executable.jar
|
|
check_file_exist ${jar_path}
|
|
jar_file=`basename "${jar_path}"`
|
|
init_instance
|
|
build_sofa
|
|
echo -e "${BLUE}occlum run SOFABoot demo${NC}"
|
|
occlum run /usr/lib/jvm/java-11-alibaba-dragonwell/jre/bin/java -Xmx512m -XX:-UseCompressedOops -XX:MaxMetaspaceSize=64m -Dos.name=Linux -jar /usr/lib/spring/${jar_file} &
|
|
}
|
|
|
|
run_sofa
|