shutdownWorkerProcess terminates gracefully a custom adapter process returns an error if it couldn't shut down gracefully (caller may abortWorkerProcess)
(ctx *customAdapterWorkerContext)
| 212 | // shutdownWorkerProcess terminates gracefully a custom adapter process |
| 213 | // returns an error if it couldn't shut down gracefully (caller may abortWorkerProcess) |
| 214 | func (a *customAdapter) shutdownWorkerProcess(ctx *customAdapterWorkerContext) error { |
| 215 | defer ctx.errTracer.Flush() |
| 216 | |
| 217 | a.Trace("xfer: Shutting down adapter worker %d", ctx.workerNum) |
| 218 | |
| 219 | finishChan := make(chan error, 1) |
| 220 | go func() { |
| 221 | termReq := NewCustomAdapterTerminateRequest() |
| 222 | err := a.sendMessage(ctx, termReq) |
| 223 | if err != nil { |
| 224 | finishChan <- err |
| 225 | } |
| 226 | ctx.stdin.Close() |
| 227 | ctx.stdout.Close() |
| 228 | finishChan <- ctx.cmd.Wait() |
| 229 | }() |
| 230 | select { |
| 231 | case err := <-finishChan: |
| 232 | return err |
| 233 | case <-time.After(30 * time.Second): |
| 234 | return errors.New(tr.Tr.Get("timeout while shutting down worker process %d", ctx.workerNum)) |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | // abortWorkerProcess terminates & aborts untidily, most probably breakdown of comms or internal error |
| 239 | func (a *customAdapter) abortWorkerProcess(ctx *customAdapterWorkerContext) { |
no test coverage detected