diff --git a/scripts-new/bricks.sh b/scripts-new/bricks.sh index 52a42613e..597d06f2a 100644 --- a/scripts-new/bricks.sh +++ b/scripts-new/bricks.sh @@ -32,6 +32,29 @@ start_binaries() { } +start_tools() { + # Assume tool_binaries=("ncpu" "infra") + for binary in "${tool_binaries[@]}"; do + local bin_full_path=$(get_tool_full_path "$binary") + # Assuming get_tool_full_path defines full path for each tool + cmd=("$bin_full_path" -c "$OPENIM_OUTPUT_CONFIG") + echo "Starting ${cmd[@]}" + "${cmd[@]}" + ret_val=$? + if [ $ret_val -eq 0 ]; then + echo "Started $bin_full_path successfully." + else + echo "Failed to start $bin_full_path with exit code $ret_val." + return 1 + fi + done + + return 0 +} + + + + #kill二进制全路径对应的进程 kill_exist_binaries(){ for binary in "${!binaries[@]}"; do diff --git a/scripts-new/define/binaries.sh b/scripts-new/define/binaries.sh index 9a8ca4a76..54f8912e0 100644 --- a/scripts-new/define/binaries.sh +++ b/scripts-new/define/binaries.sh @@ -7,3 +7,5 @@ declare -A binaries=( [openim-no-port]=2 ) + +tool_binaries=("ncpu" "infra") diff --git a/scripts-new/lib/path.sh b/scripts-new/lib/path.sh index 80cfb7e6d..5aea795fb 100644 --- a/scripts-new/lib/path.sh +++ b/scripts-new/lib/path.sh @@ -14,3 +14,8 @@ get_bin_full_path() { +get_tool_full_path() { + local tool_name="$1" + local tool_full_path="${OPENIM_OUTPUT_HOSTBIN_TOOLS}/${bin_name}" + echo ${tool_full_path} +} diff --git a/scripts-new/start.sh b/scripts-new/start.sh index 8ba1be2bf..d714510cb 100644 --- a/scripts-new/start.sh +++ b/scripts-new/start.sh @@ -12,6 +12,17 @@ source "$OPENIM_SCRIPTS/bricks.sh" # Main function to start binaries +result=$(start_tools) +ret_val=$? + + +if [ $ret_val -ne 0 ]; then + echo "tools start failed, abort start" + echo "$result" + exit 1 +fi + + kill_exist_binaries