当前位置: 首页>>代码示例>>Golang>>正文


Golang Process.Wait方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process.Wait方法的典型用法代码示例。如果您正苦于以下问题:Golang Process.Wait方法的具体用法?Golang Process.Wait怎么用?Golang Process.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process的用法示例。


在下文中一共展示了Process.Wait方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: forwardSignals

func forwardSignals(signals <-chan os.Signal, process ifrit.Process) {
	exit := process.Wait()
	for {
		select {
		case sig := <-signals:
			process.Signal(sig)
		case <-exit:
			return
		}
	}
}
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:11,代码来源:proxy.go

示例2:

				{"child1", childRunner1},
				{"child2", childRunner2},
				{"child3", childRunner3},
			}

			groupRunner = grouper.NewOrdered(os.Interrupt, members)
		})

		AfterEach(func() {
			childRunner1.EnsureExit()
			childRunner2.EnsureExit()
			childRunner3.EnsureExit()

			Eventually(started).Should(BeClosed())
			groupProcess.Signal(os.Kill)
			Eventually(groupProcess.Wait()).Should(Receive())
		})

		BeforeEach(func() {
			started = make(chan struct{})
			go func() {
				groupProcess = ifrit.Invoke(groupRunner)
				close(started)
			}()
		})

		It("runs the first runner, then the second, then becomes ready", func() {
			Eventually(childRunner1.RunCallCount).Should(Equal(1))
			Consistently(childRunner2.RunCallCount, Δ).Should(BeZero())
			Consistently(started, Δ).ShouldNot(BeClosed())
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:30,代码来源:ordered_test.go

示例3:

	})

	Context("when the daemon won't start", func() {
		fakeDeamonRunner = func(signals <-chan os.Signal, ready chan<- struct{}) error {
			close(ready)
			select {
			case signal := <-signals:
				return errors.New(signal.String())
			case <-time.After(1 * time.Second):
				// Daemon "crashes" after a while
			}
			return nil
		}

		It("times out", func() {
			err := <-lifecycle.Wait()
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("Timed out waiting for docker daemon to start"))
		})

		Context("and the process is interrupted", func() {
			BeforeEach(func() {
				lifecycle.Signal(os.Interrupt)
			})

			It("exists with error", func() {
				err := <-lifecycle.Wait()
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring("fake_docker_daemon exited with error: interrupt"))
				Expect(err.Error()).To(ContainSubstring("builder exited with error: interrupt"))
			})
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:31,代码来源:builder_runner_test.go

示例4:

		port := 8000 + GinkgoParallelNode()
		address = fmt.Sprintf("127.0.0.1:%d", port)
		server = http_server.New(address, handler)
	})

	Describe("Envoke", func() {
		var process ifrit.Process

		Context("when the server starts successfully", func() {
			BeforeEach(func() {
				process = ifrit.Envoke(server)
			})

			AfterEach(func() {
				process.Signal(syscall.SIGINT)
				Eventually(process.Wait()).Should(Receive())
			})

			Context("and a request is in flight", func() {
				type httpResponse struct {
					response *http.Response
					err      error
				}
				var responses chan httpResponse

				BeforeEach(func() {
					responses = make(chan httpResponse, 1)
					go func() {
						response, err := httpGet("http://" + address)
						responses <- httpResponse{response, err}
						close(responses)
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:31,代码来源:http_server_test.go

示例5: Kill

func Kill(process ifrit.Process, intervals ...interface{}) {
	if process != nil {
		process.Signal(os.Kill)
		Eventually(process.Wait(), intervals...).Should(Receive(), "killed ginkgomon process failed to exit in time")
	}
}
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:6,代码来源:helpers.go

示例6: Interrupt

func Interrupt(process ifrit.Process, intervals ...interface{}) {
	process.Signal(os.Interrupt)
	Eventually(process.Wait(), intervals...).Should(Receive(), "interrupted ginkgomon process failed to exit in time")
}
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:4,代码来源:helpers.go

示例7:

		restarter = restart.Restarter{
			Runner: testRunner,
			Load: func(runner ifrit.Runner, err error) ifrit.Runner {
				return nil
			},
		}
	})

	JustBeforeEach(func() {
		process = ifrit.Background(restarter)
	})

	AfterEach(func() {
		process.Signal(os.Kill)
		testRunner.EnsureExit()
		Eventually(process.Wait()).Should(Receive())
	})

	Describe("Process Behavior", func() {

		It("waits for the internal runner to be ready", func() {
			Consistently(process.Ready()).ShouldNot(BeClosed())
			testRunner.TriggerReady()
			Eventually(process.Ready()).Should(BeClosed())
		})
	})

	Describe("Load", func() {

		Context("when load returns a runner", func() {
			var loadedRunner *fake_runner.TestRunner
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:31,代码来源:restart_test.go

示例8:

var _ = Describe("Process", func() {
	Context("when a process is envoked", func() {
		var pinger test_helpers.PingChan
		var pingProc ifrit.Process
		var errChan chan error

		BeforeEach(func() {
			pinger = make(test_helpers.PingChan)
			pingProc = ifrit.Envoke(pinger)
			errChan = make(chan error)
		})

		Describe("Wait()", func() {
			BeforeEach(func() {
				go func() {
					errChan <- <-pingProc.Wait()
				}()
				go func() {
					errChan <- <-pingProc.Wait()
				}()
			})

			Context("when the process exits", func() {
				BeforeEach(func() {
					go func() {
						<-pinger
					}()
				})

				It("returns the run result upon completion", func() {
					err1 := <-errChan
开发者ID:guanglinlv,项目名称:docker_app_lifecycle,代码行数:31,代码来源:process_test.go


注:本文中的github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process.Wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。