当前位置: 首页>>代码示例>>Golang>>正文


Golang deputy.Deputy类代码示例

本文整理汇总了Golang中github.com/juju/deputy.Deputy的典型用法代码示例。如果您正苦于以下问题:Golang Deputy类的具体用法?Golang Deputy怎么用?Golang Deputy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Deputy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Launch

// Launch runs a new docker container with the given process data.
func Launch(p charm.Process) (ProcDetails, error) {
	args, err := launchArgs(p)
	if err != nil {
		return ProcDetails{}, err
	}
	d := deputy.Deputy{
		Errors: deputy.FromStderr,
	}
	cmd := execCommand("docker", args...)
	out := &bytes.Buffer{}
	cmd.Stdout = out
	if err := d.Run(cmd); err != nil {
		return ProcDetails{}, err
	}
	id := string(bytes.TrimSpace(out.Bytes()))
	status, err := inspect(id)
	if err != nil {
		return ProcDetails{}, fmt.Errorf("can't get status for container %q: %s", id, err)
	}
	return ProcDetails{
		ID: strings.TrimPrefix(status.Name, "/"),
		Status: ProcStatus{
			State: status.brief(),
		},
	}, nil
}
开发者ID:ericsnowcurrently,项目名称:juju-process-docker,代码行数:27,代码来源:docker.go

示例2: inspect

// inspect calls docker inspect and returns the unmarshaled json response.
func inspect(id string) (status, error) {
	cmd := execCommand("docker", "inspect", id)
	out := &bytes.Buffer{}
	cmd.Stdout = out
	d := deputy.Deputy{
		Errors: deputy.FromStderr,
	}
	if err := d.Run(cmd); err != nil {
		return status{}, err
	}
	return statusFromInspect(id, out.Bytes())
}
开发者ID:ericsnowcurrently,项目名称:juju-process-docker,代码行数:13,代码来源:docker.go

示例3: Example

func Example() {
	// Make a new deputy that'll return the data written to stderr as the error
	// message, log everything written to stdout to this application's log,  and
	// timeout after 30 seconds.
	d := deputy.Deputy{
		Errors:    deputy.FromStderr,
		StdoutLog: func(b []byte) { log.Print(string(b)) },
		Timeout:   time.Second * 30,
	}
	if err := d.Run(exec.Command("foo")); err != nil {
		log.Print(err)
	}
}
开发者ID:tjyang,项目名称:deputy,代码行数:13,代码来源:example_test.go

示例4: Destroy

// Destroy stops and removes the docker container with the given id.
func Destroy(id string) error {
	d := deputy.Deputy{
		Errors: deputy.FromStderr,
	}
	cmd := execCommand("docker", "stop", id)
	if err := d.Run(cmd); err != nil {
		return fmt.Errorf("error while stopping container %q: %s", err)
	}

	cmd = execCommand("docker", "rm", id)
	if err := d.Run(cmd); err != nil {
		return fmt.Errorf("error while removing container %q: %s", err)
	}
	return nil
}
开发者ID:ericsnowcurrently,项目名称:juju-process-docker,代码行数:16,代码来源:docker.go

示例5: makeCatalogs

func makeCatalogs(makeCatalogsPath, repoPath string, execTimeout time.Duration) {
	makecatalogsCmd := exec.Command(
		makeCatalogsPath,
		repoPath,
	)
	d := deputy.Deputy{
		Errors:    deputy.FromStderr,
		StdoutLog: func(b []byte) { log.Println(string(b)) },
		Timeout:   time.Second * execTimeout,
	}
	if err := d.Run(makecatalogsCmd); err != nil {
		log.Println(err)
		return
	}
}
开发者ID:groob,项目名称:autopkgd,代码行数:15,代码来源:main.go

示例6: execute

func execute(cmd string) (string, error) {
	if len(cmd) == 0 {
		return "", ErrNoCommand
	}

	var value string
	d := deputy.Deputy{
		Errors: deputy.FromStderr,
		StdoutLog: func(b []byte) {
			value = string(b)
		},
	}
	if err := d.Run(exec.Command("sh", "-c", cmd)); err != nil {
		return "", err
	}
	return value, nil
}
开发者ID:artushin,项目名称:docker-build,代码行数:17,代码来源:helpers.go

示例7: runAutopkg

func runAutopkg(recipe, reportsPath, cmdPath string, check bool, execTimeout time.Duration) autopkgReport {
	autopkgCmd := exec.Command(cmdPath, "run", "--report-plist="+reportsPath+"/"+recipe)

	if check {
		autopkgCmd.Args = append(autopkgCmd.Args, "--check")
	}

	autopkgCmd.Args = append(autopkgCmd.Args, recipe)
	d := deputy.Deputy{
		Errors:    deputy.FromStderr,
		StdoutLog: func(b []byte) { log.Print(string(b)) },
		Timeout:   time.Second * execTimeout,
	}
	if err := d.Run(autopkgCmd); err != nil {
		log.Println(err)
		return autopkgReport{}
	}
	report, err := readReportPlist(reportsPath + "/" + recipe)
	if err != nil {
		log.Println(err)
		return autopkgReport{}
	}
	return report
}
开发者ID:groob,项目名称:autopkgd,代码行数:24,代码来源:main.go


注:本文中的github.com/juju/deputy.Deputy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。