本文整理汇总了Golang中github.com/cloudfoundry-incubator/diego-ssh/server.Server.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:Golang Server.Shutdown方法的具体用法?Golang Server.Shutdown怎么用?Golang Server.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/diego-ssh/server.Server
的用法示例。
在下文中一共展示了Server.Shutdown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
})
JustBeforeEach(func() {
sshProxy = proxy.New(logger.Session("proxy"), proxySSHConfig)
proxyServer = server.NewServer(logger, "127.0.0.1:0", sshProxy)
proxyServer.SetListener(proxyListener)
go proxyServer.Serve()
sshDaemon = daemon.New(logger.Session("sshd"), daemonSSHConfig, daemonGlobalRequestHandlers, daemonNewChannelHandlers)
sshdServer = server.NewServer(logger, "127.0.0.1:0", sshDaemon)
sshdServer.SetListener(sshdListener)
go sshdServer.Serve()
})
AfterEach(func() {
proxyServer.Shutdown()
sshdServer.Shutdown()
})
Context("when a new connection arrives", func() {
var clientConfig *ssh.ClientConfig
BeforeEach(func() {
clientConfig = &ssh.ClientConfig{
User: "diego:some-instance-guid",
Auth: []ssh.AuthMethod{
ssh.Password("diego-user:diego-password"),
},
}
})
示例2:
newChannelHandlers := map[string]handlers.NewChannelHandler{
"direct-tcpip": handler,
}
serverNetConn, clientNetConn := test_helpers.Pipe()
sshd = daemon.New(logger, serverSSHConfig, nil, newChannelHandlers)
go sshd.HandleConnection(serverNetConn)
client = test_helpers.NewClient(clientNetConn, nil)
})
AfterEach(func() {
client.Close()
echoServer.Shutdown()
})
Context("when a session is opened", func() {
var conn net.Conn
JustBeforeEach(func() {
var dialErr error
conn, dialErr = client.Dial("tcp", echoAddress)
Expect(dialErr).NotTo(HaveOccurred())
})
AfterEach(func() {
conn.Close()
})
示例3:
})
})
Describe("Shutdown", func() {
var fakeListener *fake_net.FakeListener
BeforeEach(func() {
fakeListener = &fake_net.FakeListener{}
srv = server.NewServer(logger, address, handler)
srv.SetListener(fakeListener)
})
Context("when the server is shutdown", func() {
BeforeEach(func() {
srv.Shutdown()
})
It("closes the listener", func() {
Expect(fakeListener.CloseCallCount()).To(Equal(1))
})
It("marks the server as stopping", func() {
Expect(srv.IsStopping()).To(BeTrue())
})
It("does not log an accept failure", func() {
Eventually(func() error {
_, err := net.Dial("tcp", address)
return err
}).Should(HaveOccurred())