Script Refactoring

This commit is contained in:
skiffer-git 2024-04-02 11:06:34 +08:00
parent 4920b20d5a
commit 07a9deb297
2 changed files with 33 additions and 0 deletions

View File

@ -2873,6 +2873,20 @@ check_binary_ports() {
}
kill_binary() {
binary_path="$1"
pids=$(pgrep -f "$binary_path")
if [ -z "$pids" ]; then
echo "No process found for $binary_path"
else
for pid in $pids; do
echo "Killing process $pid associated with $binary_path"
kill -9 "$pid"
done
fi
}

19
scripts-new/stop.sh Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/
source "${OPENIM_ROOT}/lib/util.sh"
source "${OPENIM_ROOT}/define/binaries.sh"
source "${OPENIM_ROOT}/lib/path.sh"
for binary in "${!binaries[@]}"; do
expected_count=${binaries[$binary]}
full_path=$(get_bin_full_path "$binary")
kill_binary "$full_path"
done