in internal/langserver/langserver.go [88:112]
func (ls *langServer) StartAndWait(reader io.Reader, writer io.WriteCloser) error {
srv, err := ls.startServer(reader, writer)
if err != nil {
return err
}
ls.logger.Printf("Starting server (pid %d; concurrency: %d) ...",
os.Getpid(), ls.srvOptions.Concurrency)
// Wrap waiter with a context so that we can cancel it here
// after the service is cancelled (and srv.Wait returns)
ctx, cancelFunc := context.WithCancel(ls.srvCtx)
go func() {
srv.Wait()
cancelFunc()
}()
select { //nolint
case <-ctx.Done():
ls.logger.Printf("Stopping server (pid %d) ...", os.Getpid())
srv.Stop()
}
ls.logger.Printf("Server (pid %d) stopped.", os.Getpid())
return nil
}