本文整理汇总了Golang中github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process.Signal方法的典型用法代码示例。如果您正苦于以下问题:Golang Process.Signal方法的具体用法?Golang Process.Signal怎么用?Golang Process.Signal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process
的用法示例。
在下文中一共展示了Process.Signal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
}
}
示例2:
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"))
})
})
})
Describe("cached tags generation", func() {
var (
builder main.Builder
dockerRegistryIPs []string
示例3:
finishRequestChan = make(chan struct{}, 1)
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}
示例4:
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())
示例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")
}
}
示例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")
}
示例7:
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() {
示例8:
<-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.Envoke(test_helpers.NoReadyRunner)
close(done)
示例9:
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/proxy"
. "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/ginkgo"
. "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/onsi/gomega"
)
var _ = Describe("Proxy", func() {
var testRunner *fake_runner.TestRunner
var process ifrit.Process
var proxySignals chan os.Signal
var receivedSignals <-chan os.Signal
BeforeEach(func() {
proxySignals = make(chan os.Signal, 1)
testRunner = fake_runner.NewTestRunner()
process = ifrit.Background(proxy.New(proxySignals, testRunner))
receivedSignals = testRunner.WaitForCall()
testRunner.TriggerReady()
})
It("sends the proxied signals to the embedded runner", func() {
proxySignals <- os.Interrupt
Eventually(receivedSignals).Should(Receive(Equal(os.Interrupt)))
})
It("sends the process signals to the embedded runner", func() {
process.Signal(os.Interrupt)
Eventually(receivedSignals).Should(Receive(Equal(os.Interrupt)))
})
})