crash report updates 3-10-26

This commit is contained in:
jester 2026-03-10 18:29:40 +00:00
parent b7afe5733a
commit 243a201a64
2 changed files with 38 additions and 12 deletions

View File

@ -72,6 +72,7 @@ type agentStatus struct {
lastError error lastError error
crashCount int crashCount int
lastCrash time.Time lastCrash time.Time
intentionalStop bool
ready bool ready bool
readySource string readySource string
readyError string readyError string
@ -141,6 +142,12 @@ func GetLastReadyAt() time.Time {
return global.lastReadyAt return global.lastReadyAt
} }
func IsIntentionalStop() bool {
global.mu.Lock()
defer global.mu.Unlock()
return global.intentionalStop
}
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
STATE SETTERS unified with logging STATE SETTERS unified with logging
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -168,6 +175,18 @@ func SetError(err error) {
global.lastError = err global.lastError = err
} }
func MarkIntentionalStop() {
global.mu.Lock()
defer global.mu.Unlock()
global.intentionalStop = true
}
func ClearIntentionalStop() {
global.mu.Lock()
defer global.mu.Unlock()
global.intentionalStop = false
}
func RecordCrash(err error) { func RecordCrash(err error) {
global.mu.Lock() global.mu.Lock()
defer global.mu.Unlock() defer global.mu.Unlock()
@ -178,6 +197,7 @@ func RecordCrash(err error) {
global.lastError = err global.lastError = err
global.crashCount++ global.crashCount++
global.lastCrash = time.Now() global.lastCrash = time.Now()
global.intentionalStop = false
global.ready = false global.ready = false
global.readySource = "" global.readySource = ""
global.readyError = fmt.Sprintf("%v", err) global.readyError = fmt.Sprintf("%v", err)

View File

@ -64,6 +64,7 @@ func StartServer(cfg *state.Config) error {
serverCmd = cmd serverCmd = cmd
serverPTY = ptmx serverPTY = ptmx
state.ClearIntentionalStop()
state.SetState(state.StateRunning) state.SetState(state.StateRunning)
state.SetError(nil) state.SetError(nil)
state.SetReadyState(false, "", "") state.SetReadyState(false, "", "")
@ -78,7 +79,11 @@ func StartServer(cfg *state.Config) error {
_ = serverPTY.Close() _ = serverPTY.Close()
} }
if err != nil { if state.IsIntentionalStop() {
state.ClearIntentionalStop()
state.SetState(state.StateIdle)
state.SetReadyState(false, "", "")
} else if err != nil {
state.RecordCrash(err) state.RecordCrash(err)
} else { } else {
state.SetState(state.StateIdle) state.SetState(state.StateIdle)
@ -105,6 +110,7 @@ func StopServer() error {
} }
state.SetState(state.StateStopping) state.SetState(state.StateStopping)
state.MarkIntentionalStop()
state.SetReadyState(false, "", "") state.SetReadyState(false, "", "")
// Try graceful stop // Try graceful stop