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


Golang ServiceAction.String方法代碼示例

本文整理匯總了Golang中github.com/docker/machine/libmachine/provision/pkgaction.ServiceAction.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceAction.String方法的具體用法?Golang ServiceAction.String怎麽用?Golang ServiceAction.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/machine/libmachine/provision/pkgaction.ServiceAction的用法示例。


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

示例1: Service

func (provisioner *CoreOSProvisioner) Service(name string, action pkgaction.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:hartsock,項目名稱:machine,代碼行數:25,代碼來源:coreos.go

示例2: Service

func (provisioner *RancherProvisioner) Service(name string, action pkgaction.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:phusl,項目名稱:machine,代碼行數:9,代碼來源:rancheros.go

示例3: Service

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

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

	return nil
}
開發者ID:robebeye,項目名稱:machine,代碼行數:9,代碼來源:ubuntu.go

示例4: Service

func (provisioner *Boot2DockerProvisioner) Service(name string, action pkgaction.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:robebeye,項目名稱:machine,代碼行數:11,代碼來源:boot2docker.go

示例5: Service

func (provisioner *Boot2DockerProvisioner) Service(name string, action pkgaction.ServiceAction) error {
	var (
		cmd *exec.Cmd
		err error
	)
	cmd, err = provisioner.SSHCommand(fmt.Sprintf("sudo /etc/init.d/%s %s", name, action.String()))
	if err != nil {
		return err
	}
	if err := cmd.Run(); err != nil {
		return err
	}
	return nil
}
開發者ID:Aorjoa,項目名稱:Machine-Aiyara,代碼行數:14,代碼來源:boot2docker.go

示例6: Service

func (provisioner *DebianProvisioner) Service(name string, action pkgaction.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
	}

	return nil
}
開發者ID:nunofgs,項目名稱:docker-machine,代碼行數:14,代碼來源:debian.go

示例7: Service

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

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

	if err := cmd.Run(); err != nil {
		return err
	}

	return nil
}
開發者ID:Aorjoa,項目名稱:Machine-Aiyara,代碼行數:14,代碼來源:aiyara.go

示例8: Service

func (provisioner *RedHatProvisioner) Service(name string, action pkgaction.ServiceAction) error {
	reloadDaemon := false
	switch action {
	case pkgaction.Start, pkgaction.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 {
		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
	}

	return nil
}
開發者ID:phusl,項目名稱:machine,代碼行數:24,代碼來源:redhat.go


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