Exemplo n.º 1
0
func BootServicesAndChain(do *definitions.Do, dapp *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	// TODO: refactor this logic, should only need to call services.StartGroup(srvs)
	if len(srvs) >= 1 {
		wg, ch := new(sync.WaitGroup), make(chan error, 1)
		services.StartGroup(ch, wg, srvs)
		go func() {
			wg.Wait()
			ch <- nil
		}()
		if err := <-ch; err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if dapp.ChainName == "" {
			logger.Infof("No chain was given, booting a throwaway chain.\n")
			err = bootThrowAwayChain(dapp.Name, do)
		} else {
			logger.Infof("Booting chain =>\t\t%s\n", dapp.ChainName)
			err = bootChain(dapp.ChainName, do)
		}
	case "t", "tmp", "temp":
		logger.Infof("No chain was given, booting a throwaway chain.\n")
		err = bootThrowAwayChain(dapp.Name, do)
	default:
		logger.Infof("Booting chain =>\t\t%s\n", do.ChainName)
		err = bootChain(do.ChainName, do)
	}

	dapp.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

	return nil
}
Exemplo n.º 2
0
func BootServicesAndChain(do *definitions.Do, app *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	if len(srvs) >= 1 {
		if err := services.StartGroup(srvs); err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if app.ChainName == "" {
			// TODO [csk]: first check if there is a chain checked out. if not, then use throwAway
			log.Info("No chain was given, booting a throwaway chain")
			err = bootThrowAwayChain(app.Name, do)
		} else {
			log.WithField("=>", app.ChainName).Info("Booting chain")
			err = bootChain(app.ChainName, do)
		}
	case "t", "tmp", "temp":
		log.Info("No chain was given, booting a throwaway chain")
		err = bootThrowAwayChain(app.Name, do)
	default:
		log.WithField("=>", do.ChainName).Info("Booting chain")
		err = bootChain(do.ChainName, do)
	}

	app.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

	return nil
}
Exemplo n.º 3
0
func BootServicesAndChain(do *definitions.Do, dapp *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	if len(srvs) >= 1 {
		if err := services.StartGroup(srvs); err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if dapp.ChainName == "" {
			logger.Infof("No chain was given, booting a throwaway chain.\n")
			err = bootThrowAwayChain(dapp.Name, do)
		} else {
			logger.Infof("Booting chain =>\t\t%s\n", dapp.ChainName)
			err = bootChain(dapp.ChainName, do)
		}
	case "t", "tmp", "temp":
		logger.Infof("No chain was given, booting a throwaway chain.\n")
		err = bootThrowAwayChain(dapp.Name, do)
	default:
		logger.Infof("Booting chain =>\t\t%s\n", do.ChainName)
		err = bootChain(do.ChainName, do)
	}

	dapp.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

	return nil
}