當前位置: 首頁>>代碼示例>>Golang>>正文


Golang services.EnsureRunning函數代碼示例

本文整理匯總了Golang中github.com/eris-ltd/eris-cli/services.EnsureRunning函數的典型用法代碼示例。如果您正苦於以下問題:Golang EnsureRunning函數的具體用法?Golang EnsureRunning怎麽用?Golang EnsureRunning使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了EnsureRunning函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ImportKey

func ImportKey(do *definitions.Do) error {

	do.Name = "keys"
	do.Operations.ContainerNumber = 1
	if err := srv.EnsureRunning(do); err != nil {
		return err
	}

	do.Operations.Interactive = false
	dir := path.Join(ErisContainerRoot, "keys", "data", do.Address)
	do.Operations.Args = []string{"mkdir", dir} //need to mkdir for import
	if err := srv.ExecService(do); err != nil {
		return err
	}
	//src on host

	if do.Source == "" {
		do.Source = filepath.Join(KeysPath, "data", do.Address, do.Address)
	}
	//dest in container
	do.Destination = dir

	if err := data.ImportData(do); err != nil {
		return err
	}
	return nil
}
開發者ID:mxjxn,項目名稱:eris-cli,代碼行數:27,代碼來源:writers.go

示例2: MakeGenesisFile

func MakeGenesisFile(do *def.Do) error {

	//otherwise it'll start its own keys server that won't have the key needed...
	do.Name = "keys"
	IfExit(srv.EnsureRunning(do))

	doThr := def.NowDo()
	doThr.Chain.ChainType = "throwaway" //for teardown
	doThr.Name = "default"
	doThr.Operations.ContainerNumber = 1
	doThr.Operations.PublishAllPorts = true

	logger.Infof("Starting chain from MakeGenesisFile =>\t%s\n", doThr.Name)
	if er := StartChain(doThr); er != nil {
		return fmt.Errorf("error starting chain %v\n", er)
	}

	doThr.Operations.Args = []string{"mintgen", "known", do.Chain.Name, fmt.Sprintf("--pub=%s", do.Pubkey)}
	doThr.Chain.Name = "default" //for teardown

	// pipe this output to /chains/chainName/genesis.json
	err := ExecChain(doThr)
	if err != nil {
		logger.Printf("exec chain err: %v\nCleaning up...\n", err)
		doThr.Rm = true
		doThr.RmD = true
		if err := CleanUp(doThr); err != nil {
			return err
		}
	}

	doThr.Rm = true
	doThr.RmD = true
	return CleanUp(doThr) // doesn't clean up keys but that's ~ ok b/c it's about to be used...
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:35,代碼來源:writer.go

示例3: ensureRunning

func ensureRunning() {
	doNow := definitions.NowDo()
	doNow.Name = "ipfs"
	err := services.EnsureRunning(doNow)
	if err != nil {
		fmt.Printf("Failed to ensure IPFS is running: %v", err)
		return
	}
	logger.Infoln("IPFS is running.")
}
開發者ID:alexandrev,項目名稱:eris-cli,代碼行數:10,代碼來源:handle.go

示例4: ConvertKey

func ConvertKey(do *definitions.Do) error {

	do.Name = "keys"
	if err := srv.EnsureRunning(do); err != nil {
		return err
	}

	do.Operations.Args = []string{"mintkey", "mint", do.Address}
	if err := srv.ExecService(do); err != nil {
		return err
	}
	return nil
}
開發者ID:mxjxn,項目名稱:eris-cli,代碼行數:13,代碼來源:writers.go

示例5: GenerateKey

func GenerateKey(do *definitions.Do) error {
	do.Name = "keys"
	do.Operations.ContainerNumber = 1

	if err := srv.EnsureRunning(do); err != nil {
		return err
	}
	do.Operations.Interactive = false
	do.Operations.Args = []string{"eris-keys", "gen", "--no-pass"}

	if err := srv.ExecService(do); err != nil {
		return err
	}
	return nil
}
開發者ID:antonylewis,項目名稱:eris-cli,代碼行數:15,代碼來源:writers.go

示例6: GetPubKey

func GetPubKey(do *definitions.Do) error {

	do.Name = "keys"
	do.Operations.ContainerNumber = 1
	if err := srv.EnsureRunning(do); err != nil {
		return err
	}

	do.Operations.Interactive = false
	do.Operations.Args = []string{"eris-keys", "pub", "--addr", do.Address}

	if err := srv.ExecService(do); err != nil {
		return err
	}
	return nil
}
開發者ID:mxjxn,項目名稱:eris-cli,代碼行數:16,代碼來源:writers.go

示例7: GetFiles

func GetFiles(do *definitions.Do) error {
	doNow := definitions.NowDo()
	doNow.Name = "ipfs"
	err := services.EnsureRunning(doNow)
	if err != nil {
		return err
	}
	logger.Infoln("IPFS is running.")
	logger.Debugf("Gonna Import a file =>\t\t%s:%v\n", do.Name, do.Path)
	err = importFile(do.Name, do.Path)
	if err != nil {
		return err
	}
	do.Result = "success"
	return nil
}
開發者ID:slowtokyo,項目名稱:eris-cli,代碼行數:16,代碼來源:handle.go

示例8: ListPinned

func ListPinned(do *definitions.Do) error {
	var hash string
	doNow := definitions.NowDo()
	doNow.Name = "ipfs"
	err := services.EnsureRunning(doNow)
	if err != nil {
		return err
	}
	logger.Infoln("IPFS is running.")
	logger.Debugf("Listing files pinned locally")
	hash, err = listPinned()
	if err != nil {
		return err
	}
	do.Result = hash
	return nil
}
開發者ID:slowtokyo,項目名稱:eris-cli,代碼行數:17,代碼來源:handle.go

示例9: ListFiles

func ListFiles(do *definitions.Do) error {
	var hash string
	doNow := definitions.NowDo()
	doNow.Name = "ipfs"
	err := services.EnsureRunning(doNow)
	if err != nil {
		return err
	}
	logger.Infoln("IPFS is running.")
	logger.Debugf("Gonna List an object =>\t\t%s:%v\n", do.Name, do.Path)
	hash, err = listFile(do.Name)
	if err != nil {
		return err
	}
	do.Result = hash
	return nil
}
開發者ID:slowtokyo,項目名稱:eris-cli,代碼行數:17,代碼來源:handle.go

示例10: ListKeys

func ListKeys(do *definitions.Do) error {
	if do.Host {
		keysPath := filepath.Join(KeysPath, "data")
		addrs, err := ioutil.ReadDir(keysPath)
		if err != nil {
			return err
		}
		hostAddrs := make([]string, len(addrs))
		for i, addr := range addrs {
			hostAddrs[i] = addr.Name()
		}
		do.Result = strings.Join(hostAddrs, ",")
		log.WithField("=>", hostAddrs[0]).Warn("The keys on your host kind marmot:")
		hostAddrs = append(hostAddrs[:0], hostAddrs[1:]...)
		for _, addr := range hostAddrs {
			log.WithField("=>", addr).Warn()
		}
	}

	if do.Container {
		keysOut := new(bytes.Buffer)
		config.GlobalConfig.Writer = keysOut
		do.Name = "keys"
		do.Operations.ContainerNumber = 1
		if err := srv.EnsureRunning(do); err != nil {
			return err
		}

		do.Operations.Interactive = false
		do.Operations.Args = []string{"ls", "/home/eris/.eris/keys/data"}

		if err := srv.ExecService(do); err != nil {
			return err
		}
		keysOutString := strings.Split(util.TrimString(string(keysOut.Bytes())), "\n")
		do.Result = strings.Join(keysOutString, ",")
		log.WithField("=>", keysOutString[0]).Warn("The keys in your container kind marmot:")
		keysOutString = append(keysOutString[:0], keysOutString[1:]...)
		for _, addr := range keysOutString {
			log.WithField("=>", addr).Warn()
		}

	}
	return nil
}
開發者ID:antonylewis,項目名稱:eris-cli,代碼行數:45,代碼來源:readers.go

示例11: ExportKey

func ExportKey(do *definitions.Do) error {

	do.Name = "keys"
	do.Operations.ContainerNumber = 1
	if err := srv.EnsureRunning(do); err != nil {
		return err
	}
	//destination on host
	if do.Destination == "" {
		do.Destination = filepath.Join(KeysPath, "data")
	}
	//src in container
	do.Source = path.Join(ErisContainerRoot, "keys", "data", do.Address)
	if err := data.ExportData(do); err != nil {
		return err
	}
	return nil
}
開發者ID:mxjxn,項目名稱:eris-cli,代碼行數:18,代碼來源:writers.go

示例12: ExportChain

// export a chain definition file
func ExportChain(do *definitions.Do) error {
	chain, err := loaders.LoadChainDefinition(do.Name, false, do.Operations.ContainerNumber)
	if err != nil {
		return err
	}
	if IsChainExisting(chain) {
		doNow := definitions.NowDo()
		doNow.Name = "ipfs"
		services.EnsureRunning(doNow)

		hash, err := exportFile(do.Name)
		if err != nil {
			return err
		}
		log.Warn(hash)

	} else {
		return fmt.Errorf(`I don't known of that chain.
Please retry with a known chain.
To find known chains use: eris chains ls --known`)
	}
	return nil
}
開發者ID:mxjxn,項目名稱:eris-cli,代碼行數:24,代碼來源:manage.go

示例13: EnsureService

func EnsureService(cmd *cobra.Command, args []string) {
	IfExit(ArgCheck(1, "ge", cmd, args))
	do.Name = args[0]
	IfExit(srv.EnsureRunning(do))
}
開發者ID:jumanjiman,項目名稱:eris-cli,代碼行數:5,代碼來源:services.go


注:本文中的github.com/eris-ltd/eris-cli/services.EnsureRunning函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。