fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

indexserver: send sigquit before sigkill to stalled index (#123)

We now send sigquit first. This allows the process output a useful
stackdump of where it is stuck. We follow up with sigkill if the process
is still running after 10s.

+18 -3
+18 -3
cmd/zoekt-sourcegraph-indexserver/main.go
··· 24 24 "sort" 25 25 "strings" 26 26 "sync" 27 + "syscall" 27 28 "time" 28 29 29 30 "cloud.google.com/go/profiler" ··· 173 174 errC <- cmd.Wait() 174 175 }() 175 176 177 + // This channel is set after we have sent sigquit. It allows us to follow up 178 + // with a sigkill if the process doesn't quit after sigquit. 179 + kill := make(<-chan time.Time) 180 + 176 181 lastLen := 0 177 182 for { 178 183 select { ··· 182 187 lastLen = out.Len() 183 188 log.Printf("still running %s", cmd.Args) 184 189 } else { 185 - log.Printf("no output for %s, killing %s", noOutputTimeout, cmd.Args) 186 - if err := cmd.Process.Kill(); err != nil { 187 - log.Println("kill failed:", err) 190 + // Send quit (C-\) first so we get a stack dump. 191 + log.Printf("no output for %s, quitting %s", noOutputTimeout, cmd.Args) 192 + if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil { 193 + log.Println("quit failed:", err) 188 194 } 195 + 196 + // send sigkill if still running in 10s 197 + kill = time.After(10 * time.Second) 198 + } 199 + 200 + case <-kill: 201 + log.Printf("still running, killing %s", cmd.Args) 202 + if err := cmd.Process.Kill(); err != nil { 203 + log.Println("kill failed:", err) 189 204 } 190 205 191 206 case err := <-errC: