本文整理汇总了Golang中google/golang.org/grpc.Server.GracefulStop方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.GracefulStop方法的具体用法?Golang Server.GracefulStop怎么用?Golang Server.GracefulStop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google/golang.org/grpc.Server
的用法示例。
在下文中一共展示了Server.GracefulStop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
//.........这里部分代码省略.........
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))
pc := &cmd.PortConfig{
HTTPPort: 80,
HTTPSPort: 443,
TLSPort: 443,
}
if c.VA.PortConfig.HTTPPort != 0 {
pc.HTTPPort = c.VA.PortConfig.HTTPPort
}
if c.VA.PortConfig.HTTPSPort != 0 {
pc.HTTPSPort = c.VA.PortConfig.HTTPSPort
}
if c.VA.PortConfig.TLSPort != 0 {
pc.TLSPort = c.VA.PortConfig.TLSPort
}
sbc := newGoogleSafeBrowsing(c.VA.GoogleSafeBrowsing)
var cdrClient *cdr.CAADistributedResolver
if c.VA.CAADistributedResolver != nil {
var err error
cdrClient, err = cdr.New(
scope,
c.VA.CAADistributedResolver.Timeout.Duration,
c.VA.CAADistributedResolver.MaxFailures,
c.VA.CAADistributedResolver.Proxies,
logger)
cmd.FailOnError(err, "Failed to create CAADistributedResolver")
}
dnsTimeout, err := time.ParseDuration(c.Common.DNSTimeout)
cmd.FailOnError(err, "Couldn't parse DNS timeout")
dnsTries := c.VA.DNSTries
if dnsTries < 1 {
dnsTries = 1
}
clk := clock.Default()
caaSERVFAILExceptions, err := bdns.ReadHostList(c.VA.CAASERVFAILExceptions)
cmd.FailOnError(err, "Couldn't read CAASERVFAILExceptions file")
var resolver bdns.DNSResolver
if !c.Common.DNSAllowLoopbackAddresses {
r := bdns.NewDNSResolverImpl(
dnsTimeout,
[]string{c.Common.DNSResolver},
caaSERVFAILExceptions,
scope,
clk,
dnsTries)
resolver = r
} else {
r := bdns.NewTestDNSResolverImpl(dnsTimeout, []string{c.Common.DNSResolver}, scope, clk, dnsTries)
resolver = r
}
vai := va.NewValidationAuthorityImpl(
pc,
sbc,
cdrClient,
resolver,
c.VA.UserAgent,
c.VA.IssuerDomain,
scope,
clk,
logger)
amqpConf := c.VA.AMQP
var grpcSrv *grpc.Server
if c.VA.GRPC != nil {
s, l, err := bgrpc.NewServer(c.VA.GRPC, scope)
cmd.FailOnError(err, "Unable to setup VA gRPC server")
err = bgrpc.RegisterValidationAuthorityGRPCServer(s, vai)
cmd.FailOnError(err, "Unable to register VA gRPC server")
go func() {
err = s.Serve(l)
cmd.FailOnError(err, "VA gRPC service failed")
}()
grpcSrv = s
}
vas, err := rpc.NewAmqpRPCServer(amqpConf, c.VA.MaxConcurrentRPCServerRequests, scope, logger)
cmd.FailOnError(err, "Unable to create VA RPC server")
go cmd.CatchSignals(logger, func() {
vas.Stop()
if grpcSrv != nil {
grpcSrv.GracefulStop()
}
})
err = rpc.NewValidationAuthorityServer(vas, vai)
cmd.FailOnError(err, "Unable to setup VA RPC server")
go cmd.DebugServer(c.VA.DebugAddr)
go cmd.ProfileCmd(scope)
err = vas.Start(amqpConf)
cmd.FailOnError(err, "Unable to run VA RPC server")
}