add panic func in case of early exit

During 1st test monitor quit early with no error. Subsequent runs were fine. Added this func to give a wee bit of feedback for next time.
This commit is contained in:
Matt Wilkie
2025-11-19 14:44:26 -07:00
parent e36baee506
commit 2682fc7003
2 changed files with 18 additions and 0 deletions

View File

@@ -48,6 +48,13 @@ var (
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "PANIC in main: %v\n", r)
}
fmt.Println("Main function exiting")
}()
flag.Parse()
// Find database path if not specified
@@ -319,6 +326,11 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
// handleWebSocketBroadcast sends messages to all connected WebSocket clients
func handleWebSocketBroadcast() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "PANIC in handleWebSocketBroadcast: %v\n", r)
}
}()
for {
// Wait for message to broadcast
message := <-wsBroadcast
@@ -340,6 +352,11 @@ func handleWebSocketBroadcast() {
// pollMutations polls the daemon for mutations and broadcasts them to WebSocket clients
func pollMutations() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "PANIC in pollMutations: %v\n", r)
}
}()
lastPollTime := int64(0) // Start from beginning
ticker := time.NewTicker(2 * time.Second) // Poll every 2 seconds