Ejemplo n.º 1
0
func RunPackage(do *definitions.Do) error {
	logger.Debugf("Welcome! Say the Marmots. Running DApp package.\n")
	pwd, err := os.Getwd()
	if err != nil {
		return fmt.Errorf("Could not get the present working directory. Are you on Mars?\nError: %v\n", err)
	}

	logger.Debugf("\twith Host Path =>\t%s:%s\n", do.Path, pwd)
	dapp, err := loaders.LoadContractPackage(do.Path, do.ChainName, do.Name, do.Type)
	if err != nil {
		do.Result = "could not load package"
		return err
	}

	if err := BootServicesAndChain(do, dapp); err != nil {
		do.Result = "could not boot chain or services"
		CleanUp(do, dapp)
		return err
	}

	do.Path = pwd
	if err := DefineDappActionService(do, dapp); err != nil {
		do.Result = "could not define dapp action service"
		CleanUp(do, dapp)
		return err
	}

	if err := PerformDappActionService(do, dapp); err != nil {
		do.Result = "could not perform dapp action service"
		CleanUp(do, dapp)
		return err
	}

	if err := CleanUp(do, dapp); err != nil {
		do.Result = "could not cleanup"
		return err
	}

	do.Result = "success"
	return nil
}
Ejemplo n.º 2
0
func RunPackage(do *definitions.Do) error {
	log.Debug("Welcome! Say the marmots. Running app package")
	var err error
	pwd, err = os.Getwd()
	if err != nil {
		return fmt.Errorf("Could not get the present working directory. Are you on Mars?\nError: %v\n", err)
	}

	log.WithFields(log.Fields{
		"host path": do.Path,
		"pwd":       pwd,
	}).Debug()
	app, err := loaders.LoadContractPackage(do.Path, do.ChainName, do.Name, do.Type)
	if err != nil {
		do.Result = "could not load package"
		return err
	}

	if err := BootServicesAndChain(do, app); err != nil {
		do.Result = "could not boot chain or services"
		CleanUp(do, app)
		return err
	}

	do.Path = pwd
	if err := DefineAppActionService(do, app); err != nil {
		do.Result = "could not define app action service"
		CleanUp(do, app)
		return err
	}

	if err := PerformAppActionService(do, app); err != nil {
		do.Result = "could not perform app action service"
		CleanUp(do, app)
		return err
	}

	do.Result = "success"
	return CleanUp(do, app)
}