On 3/23/21 11:59 PM, Kurtis Rader wrote: > It sounds as if you might be running your "REST endpoint" program from > an interactive shell (i.e., a terminal) and sending SIGTERM by > pressing something like Ctrl-C. Interactive job control, which > includes how signals generated by a "terminal" are handled, is a > complex topic. So we need to know how you are sending SIGTERM to your > process. Is it by something like the `kill` command or syscall to a > specific PID or by pressing keys on your terminal to terminate the > process?
The application is installed as a service and managed via systemctl start/stop. There are two types of children -- one type simply runs and then exits: It's run like this... funcextractFeatures(s session.Session) (string, error) { output, err:= exec.Command( "./signatureml", //"-debug", "-model", "theModel", "--no-csv-header", "-csv", s.ArtifactsPath(), s.MessagePath()).CombinedOutput() returnstring(output[:]), err } The other type is long-running and communicates via stdin/stdout: It's run like this... > typeLongRunningPredictorstruct{ > theCommand *exec.Cmd > input io.WriteCloser > output bytes.Buffer > completionError error > hasEnded bool > } > func(p *LongRunningPredictor) waitLoop() { > p.hasEnded= false > p.completionError= p.theCommand.Wait() > p.hasEnded= true > } > func(p *LongRunningPredictor) start() string{ > p.theCommand= exec.Command("./long-running-predictor", "trained-model") > p.theCommand.Stdout= &p.output > p.theCommand.Stderr= &p.output > p.input, _= p.theCommand.StdinPipe() > p.theCommand.Start() > startupText, _:= readLinesUpToPrefixBestEffort(&p.output, "Ready") > gop.waitLoop() > returnstartupText > } Long running predictors are cycled through a channel that acts like a pool -- when one is needed it's pulled from the channel, and when it's done it's put back to be re-used. === Once the rest endpoint app gets the signal to terminate these children are killed even though, in theory, the signal was captured. I know the signal was captured because the logic I have in place for a clean shutdown begins to execute as expected. Looking forward to a solution or at least an understanding. Best, _M -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c14fa575-4536-1476-4222-8cfad52ce15f%40gmail.com.