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


Golang Process.Signal方法代码示例

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


在下文中一共展示了Process.Signal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:qinguoan,项目名称:vulcan,代码行数:11,代码来源:proxy.go

示例2:

						completedTasks := getTasksByState(bbsClient, models.Task_Completed)
						return failedTasks(completedTasks)
					}, 10*convergeRepeatInterval).Should(HaveLen(1))
				})
			})
		})
	})

	Describe("signal handling", func() {
		BeforeEach(func() {
			startConverger()
		})

		Describe("when it receives SIGINT", func() {
			It("exits successfully", func() {
				convergerProcess.Signal(syscall.SIGINT)
				Eventually(runner, exitDuration).Should(Exit(0))
			})
		})

		Describe("when it receives SIGTERM", func() {
			It("exits successfully", func() {
				convergerProcess.Signal(syscall.SIGTERM)
				Eventually(runner, exitDuration).Should(Exit(0))
			})
		})
	})

	Context("when etcd is down", func() {
		BeforeEach(func() {
			etcdRunner.Stop()
开发者ID:emc-xchallenge,项目名称:converger,代码行数:31,代码来源:main_test.go

示例3: cellGuid

	util.ResetGuids()

	runnerDelegate = NewAuctionRunnerDelegate(cells)
	metricEmitterDelegate := NewAuctionMetricEmitterDelegate()
	runner = auctionrunner.New(
		runnerDelegate,
		metricEmitterDelegate,
		clock.NewClock(),
		workPool,
		logger,
	)
	runnerProcess = ifrit.Invoke(runner)
})

var _ = AfterEach(func() {
	runnerProcess.Signal(os.Interrupt)
	Eventually(runnerProcess.Wait(), 20).Should(Receive())
	workPool.Stop()
})

var _ = AfterSuite(func() {
	if !disableSVGReport {
		finishReport()
	}

	for _, sess := range sessionsToTerminate {
		sess.Kill().Wait()
	}
})

func cellGuid(index int) string {
开发者ID:emc-xchallenge,项目名称:auction,代码行数:31,代码来源:simulation_suite_test.go

示例4:

			BeforeEach(func() {
				unixHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
					w.Write([]byte("yo"))
				})
				var err error
				tmpdir, err = ioutil.TempDir(os.TempDir(), "ifrit-server-test")
				Ω(err).ShouldNot(HaveOccurred())

				socketPath = path.Join(tmpdir, "ifrit.sock")
				Ω(err).ShouldNot(HaveOccurred())
				server = http_server.NewUnixServer(socketPath, unixHandler)
				process = ifrit.Invoke(server)
			})

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

			It("serves requests with the given handler", func() {
				resp, err := httpGetUnix("unix://"+socketPath+"/", socketPath)

				Ω(err).ShouldNot(HaveOccurred())
				body, err := ioutil.ReadAll(resp.Body)
				Ω(err).ShouldNot(HaveOccurred())
				Ω(string(body)).Should(Equal("yo"))
			})
		})

		Context("when the server starts successfully", func() {
			BeforeEach(func() {
开发者ID:cloudfoundry-incubator,项目名称:routing-perf-release,代码行数:31,代码来源:http_server_test.go

示例5:

			//  a) once immediately after the task completes
			//  b) once as a result of convergence
			const expireFactor = 11
			const kickFactor = 7
			const expectedResolutionAttempts = 2

			BeforeEach(func() {
				converger = ginkgomon.Invoke(componentMaker.Converger(
					"-convergeRepeatInterval", convergeRepeatInterval.String(),
					"-expireCompletedTaskDuration", (expireFactor * convergeRepeatInterval).String(),
					"-kickTaskDuration", (kickFactor * convergeRepeatInterval).String(),
				))
			})

			AfterEach(func() {
				converger.Signal(os.Kill)
			})

			It("eventually gives up", func() {
				fakeCC.SetStagingResponseStatusCode(http.StatusServiceUnavailable)
				fakeCC.SetStagingResponseBody(`{"error": "bah!"}`)

				resp, err := stageApplication(stagingGuid, string(stagingMessage))
				Expect(err).NotTo(HaveOccurred())
				Expect(resp.StatusCode).To(Equal(http.StatusAccepted))

				numExpectedStagingResponses := task_handler.MAX_RETRIES * expectedResolutionAttempts

				Eventually(fakeCC.StagingResponses).Should(HaveLen(numExpectedStagingResponses))
				Consistently(fakeCC.StagingResponses).Should(HaveLen(numExpectedStagingResponses))
			})
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:stager_test.go

示例6:

	BeforeEach(func() {
		testRunner = fake_runner.NewTestRunner()
		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() {
开发者ID:nagyistoce,项目名称:lattice-app,代码行数:30,代码来源:restart_test.go

示例7: TestDB

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/contraband/checkin/db/postgresrunner"
	"github.com/tedsuo/ifrit"
)

func TestDB(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "DB Suite")
}

var postgresRunner postgresrunner.Runner
var dbProcess ifrit.Process

var _ = BeforeSuite(func() {
	postgresRunner = postgresrunner.Runner{
		Port: 5433 + GinkgoParallelNode(),
	}

	dbProcess = ifrit.Invoke(postgresRunner)

	postgresRunner.CreateTestDB()
})

var _ = AfterSuite(func() {
	dbProcess.Signal(os.Interrupt)
	Eventually(dbProcess.Wait(), 10*time.Second).Should(Receive())
})
开发者ID:xoebus,项目名称:checkin,代码行数:29,代码来源:db_suite_test.go

示例8:

var _ = Describe("Starting the NatsClientRunner process", func() {
	var natsClient NATSClient
	var natsClientRunner ifrit.Runner
	var natsClientProcess ifrit.Process

	BeforeEach(func() {
		natsAddress := fmt.Sprintf("127.0.0.1:%d", natsPort)
		natsClient = NewClient()
		natsClientRunner = NewClientRunner(natsAddress, "nats", "nats", lagertest.NewTestLogger("test"), natsClient)
	})

	AfterEach(func() {
		stopNATS()
		if natsClientProcess != nil {
			natsClientProcess.Signal(os.Interrupt)
			Eventually(natsClientProcess.Wait(), 5).Should(Receive())
		}
	})

	Describe("when NATS is up", func() {
		BeforeEach(func() {
			startNATS()
			natsClientProcess = ifrit.Invoke(natsClientRunner)
		})

		It("connects to NATS", func() {
			Expect(natsClient.Ping()).To(BeTrue())
		})

		It("disconnects when it receives a signal", func() {
开发者ID:glyn,项目名称:gunk,代码行数:30,代码来源:nats_client_runner_test.go

示例9:

		var err error

		fakeMetrics = new(fakes.FakeMetrics)
		fakeMetrics.NumCPUReturns(11)
		fakeMetrics.NumGoroutineReturns(888)
		fakeMetrics.LoopDevicesReturns(33)
		fakeMetrics.BackingStoresReturns(12)
		fakeMetrics.DepotDirsReturns(3)

		sink := lager.NewReconfigurableSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG), lager.DEBUG)
		serverProc, err = metrics.StartDebugServer("127.0.0.1:5123", sink, fakeMetrics)
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		serverProc.Signal(os.Kill)
	})

	It("should report the number of loop devices, backing store files and depotDirs", func() {
		resp, err := http.Get("http://127.0.0.1:5123/debug/vars")
		Expect(err).ToNot(HaveOccurred())

		defer resp.Body.Close()
		Expect(resp.StatusCode).To(Equal(http.StatusOK))

		Expect(expvar.Get("loopDevices").String()).To(Equal("33"))
		Expect(expvar.Get("backingStores").String()).To(Equal("12"))
		Expect(expvar.Get("depotDirs").String()).To(Equal("3"))
		Expect(expvar.Get("numCPUS").String()).To(Equal("11"))
		Expect(expvar.Get("numGoRoutines").String()).To(Equal("888"))
	})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:debug_test.go

示例10:

							case err := <-heartbeaterErrors:
								logger.Info("never-ready-fake-heartbeat-received-error")
								return err
							}
						}
					},
				}

				serviceClient.NewCellPresenceRunnerReturns(fakeHeartbeater)

				pingErrors <- nil
				maintainProcess = ifrit.Background(maintainer)
			})

			It("exits when signaled", func() {
				maintainProcess.Signal(os.Interrupt)
				var err error
				Eventually(maintainProcess.Wait()).Should(Receive(&err))
				Expect(err).NotTo(HaveOccurred())
				Expect(maintainProcess.Ready()).NotTo(BeClosed())
			})

			Context("when the heartbeat errors", func() {
				BeforeEach(func() {
					heartbeaterErrors <- errors.New("oh no")
					pingErrors <- nil
				})

				It("does not shut down", func() {
					Consistently(maintainProcess.Wait()).ShouldNot(Receive(), "should not shut down")
				})
开发者ID:emc-xchallenge,项目名称:rep,代码行数:31,代码来源:maintain_test.go

示例11:

		ActiveKeyLabel: "label",
	}
})

var _ = BeforeEach(func() {
	etcdRunner.Start()
	consulRunner.Start()
	consulRunner.WaitUntilReady()

	bbsRunner = bbstestrunner.New(bbsPath, bbsArgs)
	bbsProcess = ginkgomon.Invoke(bbsRunner)

	gnatsdRunner, natsClient = gnatsdrunner.StartGnatsd(natsPort)
})

var _ = AfterEach(func() {
	ginkgomon.Kill(bbsProcess)
	etcdRunner.Stop()
	consulRunner.Stop()
	gnatsdRunner.Signal(os.Interrupt)
	Eventually(gnatsdRunner.Wait(), 5).Should(Receive())
})

var _ = SynchronizedAfterSuite(func() {
	if etcdRunner != nil {
		etcdRunner.Stop()
	}
}, func() {
	gexec.CleanupBuildArtifacts()
})
开发者ID:emc-xchallenge,项目名称:route-emitter,代码行数:30,代码来源:main_suite_test.go

示例12:

			members = grouper.Members{
				{"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:cloudfoundry-incubator,项目名称:routing-perf-release,代码行数:31,代码来源:ordered_test.go

示例13: TestCCUploader

func TestCCUploader(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "CC Uploader Suite")
}

var _ = SynchronizedBeforeSuite(func() []byte {
	ccUploaderPath, err := gexec.Build("github.com/cloudfoundry-incubator/cc-uploader/cmd/cc-uploader")
	Expect(err).NotTo(HaveOccurred())
	return []byte(ccUploaderPath)
}, func(ccUploaderPath []byte) {
	fakeCCAddress := fmt.Sprintf("127.0.0.1:%d", 6767+GinkgoParallelNode())
	fakeCC = fake_cc.New(fakeCCAddress)

	ccUploaderBinary = string(ccUploaderPath)
})

var _ = SynchronizedAfterSuite(func() {
}, func() {
	gexec.CleanupBuildArtifacts()
})

var _ = BeforeEach(func() {
	fakeCCProcess = ifrit.Envoke(fakeCC)
})

var _ = AfterEach(func() {
	fakeCCProcess.Signal(os.Kill)
	Eventually(fakeCCProcess.Wait()).Should(Receive(BeNil()))
})
开发者ID:emc-xchallenge,项目名称:cc-uploader,代码行数:29,代码来源:main_suite_test.go

示例14:

			Context("and an LRP is desired", func() {
				var initialInstanceGuids []string

				BeforeEach(func() {
					err := receptorClient.CreateDesiredLRP(helpers.DefaultLRPCreateRequest(processGuid, appId, 2))
					Expect(err).NotTo(HaveOccurred())

					Eventually(runningLRPsPoller).Should(HaveLen(2))
					Eventually(helloWorldInstancePoller).Should(Equal([]string{"0", "1"}))
					initialActuals := runningLRPsPoller()
					initialInstanceGuids = []string{initialActuals[0].InstanceGuid, initialActuals[1].InstanceGuid}
				})

				Context("and the LRP goes away because its rep dies", func() {
					BeforeEach(func() {
						rep.Signal(syscall.SIGKILL)

						Eventually(runningLRPsPoller).Should(BeEmpty())
						Eventually(helloWorldInstancePoller).Should(BeEmpty())
					})

					Context("once the rep comes back", func() {
						BeforeEach(func() {
							rep = ginkgomon.Invoke(componentMaker.Rep())
						})

						It("eventually brings the long-running process up", func() {
							Eventually(runningLRPsPoller).Should(HaveLen(2))
							Eventually(helloWorldInstancePoller).Should(Equal([]string{"0", "1"}))

							currentActuals := runningLRPsPoller()
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:converger_test.go

示例15:

						<-pinger
					}()
				})

				It("returns the run result upon completion", func() {
					err1 := <-errChan
					err2 := <-errChan
					Ω(err1).Should(Equal(test_helpers.PingerExitedFromPing))
					Ω(err2).Should(Equal(test_helpers.PingerExitedFromPing))
				})
			})
		})

		Describe("Signal()", func() {
			BeforeEach(func() {
				pingProc.Signal(os.Kill)
			})

			It("sends the signal to the runner", func() {
				err := <-pingProc.Wait()
				Ω(err).Should(Equal(test_helpers.PingerExitedFromSignal))
			})
		})
	})

	Context("when a process exits without closing ready", func() {
		var proc ifrit.Process

		BeforeEach(func(done Done) {
			proc = ifrit.Invoke(test_helpers.NoReadyRunner)
			close(done)
开发者ID:cwlbraa,项目名称:ifrit,代码行数:31,代码来源:process_test.go


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