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


Golang ServiceAction.String方法代码示例

本文整理汇总了Golang中github.com/docker/machine/libmachine/provision/serviceaction.ServiceAction.String方法的典型用法代码示例。如果您正苦于以下问题:Golang ServiceAction.String方法的具体用法?Golang ServiceAction.String怎么用?Golang ServiceAction.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/docker/machine/libmachine/provision/serviceaction.ServiceAction的用法示例。


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

示例1: Service

func (provisioner *RedHatProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	reloadDaemon := false
	switch action {
	case serviceaction.Start, serviceaction.Restart:
		reloadDaemon = true
	}

	// systemd needs reloaded when config changes on disk; we cannot
	// be sure exactly when it changes from the provisioner so
	// we call a reload on every restart to be safe
	if reloadDaemon {
		reload_command := provisioner.Driver.SSHSudo("systemctl daemon-reload")
		if _, err := provisioner.SSHCommand(reload_command); err != nil {
			return err
		}
	}

	systemctl_command := provisioner.Driver.SSHSudo("systemctl %s %s")
	command := fmt.Sprintf(systemctl_command, action.String(), name)

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	return nil
}
开发者ID:pdxjohnny,项目名称:machine,代码行数:26,代码来源:redhat.go

示例2: Service

func (provisioner *CoreOSProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	// daemon-reload to catch config updates; systemd -- ugh
	if _, err := provisioner.SSHCommand("sudo systemctl daemon-reload"); err != nil {
		return err
	}

	command := fmt.Sprintf("sudo systemctl %s %s", action.String(), name)

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	// wait until docker is running
	if (name == "docker") && (action.String() == "start") {
		ip, err := provisioner.GetDriver().GetIP()
		if err != nil {
			return err
		}
		if err := utils.WaitForDocker(ip, 2376); err != nil {
			return err
		}
	}

	return nil
}
开发者ID:justintung,项目名称:machine,代码行数:25,代码来源:coreos.go

示例3: Service

func (provisioner *UbuntuProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	command := fmt.Sprintf("sudo service %s %s", name, action.String())

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	return nil
}
开发者ID:mschygulla,项目名称:machine,代码行数:9,代码来源:ubuntu.go

示例4: Service

func (provisioner *RancherProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	command := fmt.Sprintf("sudo system-docker %s %s", action.String(), name)

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	return nil
}
开发者ID:ChristopherBiscardi,项目名称:machine,代码行数:9,代码来源:rancheros.go

示例5: Service

func (provisioner *Boot2DockerProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	var (
		err error
	)

	if _, err = provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String())); err != nil {
		return err
	}

	return nil
}
开发者ID:justintung,项目名称:machine,代码行数:11,代码来源:boot2docker.go

示例6: Service

func (provisioner *DebianProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	// daemon-reload to catch config updates; systemd -- ugh
	if _, err := provisioner.SSHCommand("sudo systemctl daemon-reload"); err != nil {
		return err
	}

	command := fmt.Sprintf("sudo systemctl -f %s %s", action.String(), name)

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	return nil
}
开发者ID:justintung,项目名称:machine,代码行数:14,代码来源:debian.go

示例7: Service

func (provisioner *CoreOSProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	if _, err := provisioner.SSHCommand("sudo systemctl daemon-reload"); err != nil {
		return err
	}

	command := fmt.Sprintf("sudo systemctl %s %s", action.String(), name)

	if _, err := provisioner.SSHCommand(command); err != nil {
		return err
	}

	// wait until docker is running
	if (name == "docker") && (action.String() == "start") {
		if err := waitForDocker(provisioner, 2376); err != nil {
			return err
		}
	}

	return nil
}
开发者ID:yamamoto-febc,项目名称:machine,代码行数:20,代码来源:coreos.go

示例8: Service

func (provisioner *Boot2DockerProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	_, err := provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String()))
	return err
}
开发者ID:bgokden,项目名称:machine,代码行数:4,代码来源:boot2docker.go

示例9: Service

func (provisioner *WindowsProvisioner) Service(name string, action serviceaction.ServiceAction) error {
	ip, err := provisioner.Driver.GetIP()
	if err != nil {
		return err
	}
	d := provisioner.Driver
	out, stderr, exit, err := drivers.WinRMRunCmdWithNTLM(ip, d.GetSSHUsername(), d.GetSSHPassword(), fmt.Sprintf("net %s %s", action.String(), name))
	if (err != nil) || (exit != 0) {
		log.Error("service stdout:", out, ", stderr:", stderr, ", err:", err, ", exit:", exit)
		return err
	}
	return nil
}
开发者ID:containerx,项目名称:machine,代码行数:13,代码来源:windows.go


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