update-app.sh: kill by pattern EXCLUDING own process lineage — pkill -f matched any ancestor shell mentioning the script path, so an update run could SIGTERM its own invoker; app-kill now walks the ppid chain and spares it
This commit is contained in:
parent
668ecbefd0
commit
c948ca7367
1 changed files with 15 additions and 4 deletions
|
|
@ -28,13 +28,24 @@ if ! ./gradlew :app:createDistributable -q; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop the app (and its engine) only AFTER a good build exists.
|
# Stop the app (and its engine) only AFTER a good build exists.
|
||||||
|
# NEVER match our own lineage: pkill -f also matches any ancestor shell
|
||||||
|
# whose command line merely mentions this script's path.
|
||||||
|
_selfpids() { local p=$$; while [ "$p" -gt 1 ]; do echo "$p"; p=$(ps -o ppid= -p "$p" 2>/dev/null | tr -d ' '); [ -z "$p" ] && break; done; }
|
||||||
|
_killpat() {
|
||||||
|
local pat="$1" pid
|
||||||
|
for pid in $(pgrep -f "$pat" 2>/dev/null); do
|
||||||
|
case " $(_selfpids) " in *" $pid "*) continue;; esac
|
||||||
|
# also skip the pgrep call itself via its subshell parent already covered
|
||||||
|
kill "$pid" 2>/dev/null
|
||||||
|
done
|
||||||
|
}
|
||||||
# Packaged runs appear as .../bin/shonar-desktop; dev runs as java MainKt.
|
# Packaged runs appear as .../bin/shonar-desktop; dev runs as java MainKt.
|
||||||
pkill -f 'com.shonar.desktop.MainKt' 2>/dev/null
|
_killpat 'com.shonar.desktop.MainKt'
|
||||||
pkill -f 'shonar-desktop/bin/shonar-desktop' 2>/dev/null
|
_killpat 'shonar-desktop/bin/shonar-desktop'
|
||||||
pkill -f 'uvicorn shonar.main:app' 2>/dev/null
|
_killpat 'uvicorn shonar.main:app'
|
||||||
sleep 2
|
sleep 2
|
||||||
# Last resort: anything still holding a SHONAR window.
|
# Last resort: anything still holding a SHONAR window.
|
||||||
pkill -f 'shonar-desktop' 2>/dev/null
|
_killpat 'shonar-desktop'
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
bin="$repo/app/build/compose/binaries/main/app/shonar-desktop/bin/shonar-desktop"
|
bin="$repo/app/build/compose/binaries/main/app/shonar-desktop/bin/shonar-desktop"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue