func (server *ReaderServer) Stop() {
	log.Infoln("Stop accepting new connections")
	server.StopListeners()
	if server.grpcServer != nil {
		server.backgroundWorkersSync.Add(1)
		go func() {
			defer server.backgroundWorkersSync.Done()
			server.grpcServer.GracefulStop()
		}()
	}
	if server.connectionManager.Counter != 0 {
		log.Infof("Wait ending current connections (%v)", server.connectionManager.Counter)
		<-time.NewTimer(server.waitTimeout).C
	}
	log.Infof("Stop all connections that not closed (%v)", server.connectionManager.Counter)
	if server.grpcServer != nil {
		server.grpcServer.Stop()
	}
	if err := server.connectionManager.CloseConnections(); err != nil {
		log.WithField(logging.FieldKeyEventCode, logging.EventCodeErrorCantCloseConnection).WithError(err).Errorln("Took error on closing available connections")
	}
}
Stop stops AcraTranslator from accepting new connections, and gracefully close existing ones.
package server
import (
	"context"
	"errors"
	"github.com/cossacklabs/acra/utils"
	"net"
	"os"
	"sync"
	"time"
	"google.golang.org/grpc/credentials"
	"bufio"
	"net/http"
	"github.com/cossacklabs/acra/cmd/acra-translator/common"
	"github.com/cossacklabs/acra/cmd/acra-translator/http_api"
	"github.com/cossacklabs/acra/decryptor/base"
	"github.com/cossacklabs/acra/keystore"
	"github.com/cossacklabs/acra/logging"
	"github.com/cossacklabs/acra/network"
	log "github.com/sirupsen/logrus"
	"go.opencensus.io/trace"
	"google.golang.org/grpc"
)
type ReaderServer struct {
	config                *common.AcraTranslatorConfig
	keystorage            keystore.TranslationKeyStore
	connectionManager     *network.ConnectionManager
	grpcServer            *grpc.Server
	httpDecryptor         *http_api.HTTPConnectionsDecryptor
	waitTimeout           time.Duration
	grpcServerFactory     common.GRPCServerFactory
	backgroundWorkersSync sync.WaitGroup
	listenerHTTP          net.Listener
	listenerGRPC          net.Listener
}
const (
	grpcFilenamePlaceholder = "tmp/acra_translator_grpc"
	httpFilenamePlaceholder = "tmp/acra_translator_http"
)
func NewReaderServer(config *common.AcraTranslatorConfig, keystorage keystore.TranslationKeyStore, grpcServerFactory common.GRPCServerFactory, waitTimeout time.Duration) (server *ReaderServer, err error) {
	return &ReaderServer{
		grpcServerFactory: grpcServerFactory,
		waitTimeout:       waitTimeout,
		config:            config,
		keystorage:        keystorage,
		connectionManager: network.NewConnectionManager(),
	}, nil
}