fix: prevent gt down --all from respawning bd daemon (#457)

CountBdDaemons() was using `bd daemon list --json` which triggers
daemon auto-start as a side effect. During shutdown verification,
this caused a new daemon to spawn after all daemons were killed,
resulting in "bd daemon shutdown incomplete: 1 still running" error.

Replaced all `bd daemon killall` calls with pkill in:
- stopBdDaemons()
- restartBdDaemons()

Changed CountBdDaemons() to use pgrep instead of bd daemon list.
Also removed the now-unused parseBdDaemonCount helper function and its tests.
This commit is contained in:
dustin
2026-01-14 04:28:16 +07:00
committed by GitHub
parent bedccb1634
commit 66805079de
2 changed files with 13 additions and 81 deletions

View File

@@ -5,46 +5,6 @@ import (
"testing"
)
func TestParseBdDaemonCount_Array(t *testing.T) {
input := []byte(`[{"pid":1234},{"pid":5678}]`)
count := parseBdDaemonCount(input)
if count != 2 {
t.Errorf("expected 2, got %d", count)
}
}
func TestParseBdDaemonCount_ObjectWithCount(t *testing.T) {
input := []byte(`{"count":3,"daemons":[{},{},{}]}`)
count := parseBdDaemonCount(input)
if count != 3 {
t.Errorf("expected 3, got %d", count)
}
}
func TestParseBdDaemonCount_ObjectWithDaemons(t *testing.T) {
input := []byte(`{"daemons":[{},{}]}`)
count := parseBdDaemonCount(input)
if count != 2 {
t.Errorf("expected 2, got %d", count)
}
}
func TestParseBdDaemonCount_Empty(t *testing.T) {
input := []byte(``)
count := parseBdDaemonCount(input)
if count != 0 {
t.Errorf("expected 0, got %d", count)
}
}
func TestParseBdDaemonCount_Invalid(t *testing.T) {
input := []byte(`not json`)
count := parseBdDaemonCount(input)
if count != 0 {
t.Errorf("expected 0 for invalid JSON, got %d", count)
}
}
func TestCountBdActivityProcesses(t *testing.T) {
count := CountBdActivityProcesses()
if count < 0 {