本文整理匯總了Golang中github.com/eris-ltd/eris-cli/services.StartService函數的典型用法代碼示例。如果您正苦於以下問題:Golang StartService函數的具體用法?Golang StartService怎麽用?Golang StartService使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了StartService函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestServiceLinkBadChainWithoutChainInDefinition
func TestServiceLinkBadChainWithoutChainInDefinition(t *testing.T) {
defer tests.RemoveAllContainers()
if err := tests.FakeServiceDefinition(erisDir, "fake", `
[service]
name = "fake"
image = "quay.io/eris/ipfs"
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
do := def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = "non-existent-chain"
// [pv]: is this a bug? the service which doesn't have a
// "chain" in its definition file doesn't care about linking at all.
if err := services.StartService(do); err != nil {
t.Fatalf("expect service to start, got %v", err)
}
if n := util.HowManyContainersRunning("fake", def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
}
示例2: TestServiceLinkKeys
func TestServiceLinkKeys(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Name = chainName
do.Operations.ContainerNumber = 1
if err := NewChain(do); err != nil {
t.Fatalf("could not start a new chain, got %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
do = def.NowDo()
do.Operations.Args = []string{"keys"}
do.Operations.ContainerNumber = 1
do.ChainName = chainName
if err := services.StartService(do); err != nil {
t.Fatalf("expecting service to start, got %v", err)
}
if n := util.HowManyContainersExisting("keys", def.TypeService); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
links := tests.Links("keys", def.TypeService, 1)
if len(links) != 0 {
t.Fatalf("expected service links be empty, got %v", links)
}
}
示例3: StartServicesAndChains
func StartServicesAndChains(do *definitions.Do) error {
// start the services and chains
doSrvs := definitions.NowDo()
if do.Action.Dependencies == nil || len(do.Action.Dependencies.Services) == 0 {
log.Debug("No services to start")
} else {
doSrvs.Operations.Args = do.Action.Dependencies.Services
log.WithField("args", doSrvs.Operations.Args).Debug("Starting services")
if err := services.StartService(doSrvs); err != nil {
return err
}
}
doChns := definitions.NowDo()
doChns.Name = do.Action.Chain
if doChns.Name == "" {
log.Debug("No chain to start")
} else {
log.WithField("=>", doChns.Name).Debug("Starting chain")
if err := chains.StartChain(do); err != nil {
return err
}
}
return nil
}
示例4: StartServicesAndChains
func StartServicesAndChains(do *definitions.Do) error {
// start the services and chains
doSrvs := definitions.NowDo()
doSrvs.Args = do.Action.ServiceDeps
if len(doSrvs.Args) == 0 {
logger.Debugf("No services to start.\n")
} else {
logger.Debugf("Starting Services. Args =>\t%v\n", doSrvs.Args)
if err := services.StartService(doSrvs); err != nil {
return err
}
}
doChns := definitions.NowDo()
doChns.Name = do.Action.Chain
if doChns.Name == "" {
logger.Debugf("No chain to start.\n")
} else {
logger.Debugf("Starting Chain. Name =>\t\t%v\n", doChns.Name)
if err := chains.StartChain(do); err != nil {
return err
}
}
return nil
}
示例5: TestServiceLinkWithDataContainer
func TestServiceLinkWithDataContainer(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Name = chainName
do.Operations.ContainerNumber = 1
if err := NewChain(do); err != nil {
t.Fatalf("could not start a new chain, got %v", err)
}
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "$chain:fake"
[service]
name = "fake"
image = "quay.io/eris/ipfs"
data_container = true
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeService); n != 0 {
t.Fatalf("expecting 0 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 0 {
t.Fatalf("expecting 0 data containers, got %v", n)
}
do = def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = chainName
if err := services.StartService(do); err != nil {
t.Fatalf("expecting service to start, got %v", err)
}
if n := util.HowManyContainersRunning("fake", def.TypeService); n != 1 {
t.Fatalf("expecting 1 service containers, got %v", n)
}
if n := util.HowManyContainersExisting("fake", def.TypeData); n != 1 {
t.Fatalf("expecting 1 data containers, got %v", n)
}
links := tests.Links("fake", def.TypeService, 1)
if len(links) != 1 || !strings.Contains(links[0], chainName) {
t.Fatalf("expected service be linked to a test chain, got %v", links)
}
}
示例6: testStartKeys
func testStartKeys(t *testing.T) {
serviceName := "keys"
do := def.NowDo()
do.Operations.Args = []string{serviceName}
do.Operations.ContainerNumber = 1
log.WithField("=>", fmt.Sprintf("%s:%d", serviceName, do.Operations.ContainerNumber)).Debug("Starting service (via tests)")
e := srv.StartService(do)
if e != nil {
log.Infof("Error starting service: %v", e)
t.Fail()
}
testExistAndRun(t, serviceName, 1, true, true)
testNumbersExistAndRun(t, serviceName, 1, 1)
}
示例7: testStartKeys
func testStartKeys(t *testing.T) {
serviceName := "keys"
do := def.NowDo()
do.Operations.Args = []string{serviceName}
do.Operations.ContainerNumber = 1
logger.Debugf("Starting service (via tests) =>\t%s:%d\n", serviceName, do.Operations.ContainerNumber)
e := srv.StartService(do)
if e != nil {
logger.Infof("Error starting service =>\t%v\n", e)
t.Fail()
}
testExistAndRun(t, serviceName, 1, true, true)
testNumbersExistAndRun(t, serviceName, 1, 1)
}
示例8: testStartService
//from /services/services_test.go
func testStartService(t *testing.T, serviceName string, publishAll bool) {
do := def.NowDo()
do.Operations.Args = []string{serviceName}
do.Operations.ContainerNumber = 1 //util.AutoMagic(0, "service", true)
do.Operations.PublishAllPorts = publishAll
logger.Debugf("Starting service (via tests) =>\t%s:%d\n", serviceName, do.Operations.ContainerNumber)
e := srv.StartService(do)
if e != nil {
logger.Infof("Error starting service =>\t%v\n", e)
fatal(t, e)
}
testExistAndRun(t, serviceName, 1, true, true)
testNumbersExistAndRun(t, serviceName, 1, 1)
}
示例9: testStartService
//from /services/services_test.go
func testStartService(t *testing.T, serviceName string, publishAll bool) {
do := def.NowDo()
do.Operations.Args = []string{serviceName}
do.Operations.ContainerNumber = 1 //util.AutoMagic(0, "service", true)
do.Operations.PublishAllPorts = publishAll
log.WithField("=>", fmt.Sprintf("%s:%d", serviceName, do.Operations.ContainerNumber)).Debug("Starting service (from tests)")
e := srv.StartService(do)
if e != nil {
log.Infof("Error starting service: %v", e)
fatal(t, e)
}
testExistAndRun(t, serviceName, 1, true, true)
testNumbersExistAndRun(t, serviceName, 1, 1)
}
示例10: testsInit
func testsInit() error {
if err := tests.TestsInit("files"); err != nil {
return err
}
f, err := os.Create(file)
tests.IfExit(err)
f.Write([]byte(content))
do1 := definitions.NowDo()
do1.Operations.Args = []string{"ipfs"}
err = services.StartService(do1)
tests.IfExit(err)
time.Sleep(5 * time.Second) // boot time
return nil
}
示例11: TestServiceLinkBadChain
func TestServiceLinkBadChain(t *testing.T) {
defer tests.RemoveAllContainers()
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "$chain:fake"
[service]
name = "fake"
image = "quay.io/eris/ipfs"
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
do := def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = "non-existent-chain"
if err := services.StartService(do); err == nil {
t.Fatalf("expect start service to fail, got nil")
}
}
示例12: TestServiceLinkNoChain
func TestServiceLinkNoChain(t *testing.T) {
defer tests.RemoveAllContainers()
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "$chain:fake"
[service]
name = "fake"
image = "`+path.Join(ver.ERIS_REG_DEF, ver.ERIS_IMG_IPFS)+`"
data_container = true
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
do := def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
if err := services.StartService(do); err == nil {
t.Fatalf("expect start service to fail, got nil")
}
}
示例13: TestServiceLinkBadLiteral
func TestServiceLinkBadLiteral(t *testing.T) {
defer tests.RemoveAllContainers()
do := def.NowDo()
do.Name = chainName
do.Operations.ContainerNumber = 1
if err := NewChain(do); err != nil {
t.Fatalf("could not start a new chain, got %v", err)
}
if err := tests.FakeServiceDefinition(erisDir, "fake", `
chain = "blah-blah:blah"
[service]
name = "fake"
image = "quay.io/eris/ipfs"
`); err != nil {
t.Fatalf("can't create a fake service definition: %v", err)
}
if n := util.HowManyContainersExisting(chainName, def.TypeChain); n != 1 {
t.Fatalf("expecting 1 test chain containers, got %v", n)
}
do = def.NowDo()
do.Operations.Args = []string{"fake"}
do.Operations.ContainerNumber = 1
do.ChainName = chainName
// [pv]: probably a bug. Bad literal chain link in a definition
// file doesn't affect the service start. Links is not nil.
if err := services.StartService(do); err != nil {
t.Fatalf("expecting service to start, got %v", err)
}
links := tests.Links("fake", def.TypeService, 1)
if len(links) != 1 || !strings.Contains(links[0], chainName) {
t.Fatalf("expected service be linked to a test chain, got %v", links)
}
}
示例14: bootChain
func bootChain(name string, do *definitions.Do) error {
do.Chain.ChainType = "service" // setting this for tear down purposes
startChain := definitions.NowDo()
startChain.Name = name
startChain.Operations = do.Operations
err := chains.StartChain(startChain)
// errors *could* be because the chain was actually a service.
if err != nil {
if util.IsServiceContainer(name, do.Operations.ContainerNumber, true) {
startService := definitions.NowDo()
startService.Operations = do.Operations
startService.Operations.Args = []string{name}
err = services.StartService(startService)
if err != nil {
return err
}
}
} else {
do.Chain.ChainType = "chain" // setting this for tear down purposes
}
do.Chain.Name = name // setting this for tear down purposes
return nil
}
示例15: testsInit
func testsInit() error {
var err error
// TODO: make a reader/pipe so we can see what is written from tests.
config.GlobalConfig, err = config.SetGlobalObject(os.Stdout, os.Stderr)
ifExit(err)
// common is initialized on import so
// we have to manually override these
// variables to ensure that the tests
// run correctly.
config.ChangeErisDir(erisDir)
// init dockerClient
util.DockerConnect(false, "eris")
// this dumps the ipfs service def into the temp dir which
// has been set as the erisRoot
do := definitions.NowDo()
do.Pull = true
do.Services = true
do.Actions = true
ifExit(ini.Initialize(do))
// dump a test file with some stuff
f, err := os.Create(file)
ifExit(err)
f.Write([]byte(content))
do1 := definitions.NowDo()
do1.Args = []string{"ipfs"}
err = services.StartService(do1)
ifExit(err)
time.Sleep(5 * time.Second)
return nil
}