本文整理汇总了Golang中github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit.Process类的典型用法代码示例。如果您正苦于以下问题:Golang Process类的具体用法?Golang Process怎么用?Golang Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Process类的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:
"fmt"
"os"
"strings"
"time"
. "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"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/ginkgomon"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/grouper"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/builder"
)
var _ = Describe("Builder runner", func() {
var (
lifecycle ifrit.Process
fakeDeamonRunner func(signals <-chan os.Signal, ready chan<- struct{}) error
)
BeforeEach(func() {
builder := main.Builder{
RepoName: "ubuntu",
Tag: "latest",
OutputFilename: "/tmp/result/result.json",
DockerDaemonTimeout: 300 * time.Millisecond,
CacheDockerImage: true,
}
lifecycle = ifrit.Background(grouper.NewParallel(os.Interrupt, grouper.Members{
{"builder", ifrit.RunFunc(builder.Run)},
{"fake_docker_daemon", ifrit.RunFunc(fakeDeamonRunner)},
}))
示例3:
startedRequestChan <- struct{}{}
<-finishRequestChan
w.Write([]byte("yo"))
})
)
BeforeEach(func() {
startedRequestChan = make(chan struct{}, 1)
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
示例4:
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/fake_runner"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/grouper"
. "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("Ordered Group", func() {
var (
started chan struct{}
groupRunner ifrit.Runner
groupProcess ifrit.Process
members grouper.Members
childRunner1 *fake_runner.TestRunner
childRunner2 *fake_runner.TestRunner
childRunner3 *fake_runner.TestRunner
Δ time.Duration = 10 * time.Millisecond
)
Describe("Start", func() {
BeforeEach(func() {
childRunner1 = fake_runner.NewTestRunner()
childRunner2 = fake_runner.NewTestRunner()
childRunner3 = fake_runner.NewTestRunner()
members = grouper.Members{
{"child1", childRunner1},
示例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:
package restart_test
import (
"os"
. "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"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/fake_runner"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/restart"
)
var _ = Describe("Restart", func() {
var testRunner *fake_runner.TestRunner
var restarter restart.Restarter
var process ifrit.Process
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)
})
示例8:
package ifrit_test
import (
. "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"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/test_helpers"
"os"
)
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()
}()
})
示例9:
package proxy_test
import (
"os"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit"
"github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/tedsuo/ifrit/fake_runner"
"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)))
})