Fix SpacetimeDB root-dir owner detection false positives
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-27 09:18:09 +08:00
parent 8d0be677ce
commit 3c3f5ad22b
5 changed files with 82 additions and 3 deletions

View File

@@ -577,7 +577,24 @@ is_spacetime_ready() {
describe_spacetime_root_owner() {
if command -v ps >/dev/null 2>&1; then
ps -ef 2>/dev/null | grep '[s]pacetime' | grep -F "${SPACETIME_ROOT_DIR}" || true
ps -eo user=,pid=,ppid=,stat=,comm=,args= 2>/dev/null | awk -v root_dir="${SPACETIME_ROOT_DIR}" '
{
user = $1
pid = $2
ppid = $3
stat = $4
command = $5
args = $0
sub(/^[[:space:]]*[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]*/, "", args)
name = command
sub(/^.*\//, "", name)
# 只认真实的 SpacetimeDB 启动进程,避免 .spacetimedb 路径让 grep/awk 自身误命中。
if ((name == "spacetime" || name == "spacetimedb-cli") && index(args, root_dir) > 0) {
print user " " pid " " ppid " " stat " " name " " args
}
}
' || true
fi
}