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


Golang systemd.SystemdClient類代碼示例

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


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

示例1: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, subnet, dockerSubnet, gateway string, useDockerRules bool) error {
	vLogger("\n# call iptables.Setup()")

	if err := setupNetfilter(fsc); err != nil {
		return maskAny(err)
	}

	if err := setupRules(fsc, subnet, dockerSubnet, gateway, useDockerRules); err != nil {
		return maskAny(err)
	}

	if err := setupService(fsc); err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	for _, s := range services {
		if err := sc.Start(s); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:27,代碼來源:iptables.go

示例2: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, fleetVersion string, startDaemon bool, useOverlay bool) error {
	vLogger("\n# call fleet.Setup()")

	fleetdRaw, err := fc.Get("fleet/" + fleetVersion + "/fleetd")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/fleet", fleetdRaw, fileMode); err != nil {
		return maskAny(err)
	}

	if err := fsc.Symlink(distributionPath+"/fleet", distributionPath+"/fleetd"); err != nil {
		return maskAny(err)
	}

	fleetctlRaw, err := fc.Get("fleet/" + fleetVersion + "/fleetctl")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/fleetctl", fleetctlRaw, fileMode); err != nil {
		return maskAny(err)
	}

	err = createFleetService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(fleetServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:42,代碼來源:fleet.go

示例3: Teardown

func Teardown(fsc *fs.FsClient, sc *systemd.SystemdClient) error {
	vLogger("\n# call iptables.Teardown()")

	for _, s := range services {
		exists, err := sc.Exists(s)
		if err != nil {
			return maskAny(err)
		}

		if !exists {
			continue
		}

		if err := sc.Stop(s); err != nil {
			return maskAny(err)
		}
	}

	for _, p := range paths {
		if err := fsc.Remove(p); err != nil {
			return maskAny(err)
		}
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:30,代碼來源:iptables.go

示例4: Teardown

func Teardown(fsc *fs.FsClient, sc *systemd.SystemdClient, stopDaemon bool) error {
	vLogger("\n# call docker.Teardown()")

	for _, s := range services {
		exists, err := sc.Exists(s)
		if err != nil {
			return maskAny(err)
		}

		if !exists || !stopDaemon {
			continue
		}

		if err := sc.Stop(s); err != nil {
			return maskAny(err)
		}
	}

	for _, p := range paths {
		if err := fsc.Remove(p); err != nil {
			return maskAny(err)
		}
	}

	// reload unit files, that is, `systemctl daemon-reload`
	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:31,代碼來源:docker.go

示例5: Teardown

func Teardown(fsc *fs.FsClient, sc *systemd.SystemdClient, distributionPath string, stopDaemon bool) error {
	vLogger("\n# call rkt.Teardown()")

	for _, u := range units {
		exists, err := sc.Exists(u)
		if err != nil {
			return maskAny(err)
		}

		if !exists || !stopDaemon {
			continue
		}

		if err := sc.Stop(u); err != nil {
			return maskAny(err)
		}

		if err := fsc.Remove(rktSystemdPath + u); err != nil {
			return maskAny(err)
		}
	}

	// reload unit files, that is, `systemctl daemon-reload`
	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if err := fsc.Remove(distributionPath + "/rkt"); err != nil {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:33,代碼來源:rkt.go

示例6: Teardown

func Teardown(fsc *fs.FsClient, sc *systemd.SystemdClient, distributionPath, overlayWorkdir, overlayMountPoint string) error {
	vLogger("\n# call overlay.Teardown()")

	exists, err := sc.Exists(overlayMount)
	if err != nil {
		return maskAny(err)
	}

	if exists {
		if err := sc.Stop(overlayMount); err != nil {
			return maskAny(err)
		}
	}

	if err := fsc.Remove(overlayMountPath); err != nil && !fs.IsNotExist(err) {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if err := fsc.Remove(overlayWorkdir); err != nil && !fs.IsNotExist(err) {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:28,代碼來源:overlay.go

示例7: Teardown

func Teardown(fsc *fs.FsClient, sc *systemd.SystemdClient, distributionPath string, stopDaemon bool) error {
	vLogger("\n# call fleet.Teardown()")

	exists, err := sc.Exists(fleetServiceName)
	if err != nil {
		return maskAny(err)
	}

	if exists && stopDaemon {
		if err := sc.Stop(fleetServiceName); err != nil {
			return maskAny(err)
		}
	}

	if err := fsc.Remove(distributionPath + "/fleet"); err != nil {
		return maskAny(err)
	}

	if err := fsc.Remove(distributionPath + "/fleetd"); err != nil {
		return maskAny(err)
	}

	if err := fsc.Remove(distributionPath + "/fleetctl"); err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:32,代碼來源:fleet.go

示例8: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, etcdVersion string, startDaemon bool, useOverlay bool) error {
	vLogger("\n# call etcd.Setup()")

	etcdRaw, err := fc.Get("etcd/" + etcdVersion + "/etcd")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/etcd2", etcdRaw, fileMode); err != nil {
		return maskAny(err)
	}

	etcdctlRaw, err := fc.Get("etcd/" + etcdVersion + "/etcdctl")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/etcdctl", etcdctlRaw, fileMode); err != nil {
		return maskAny(err)
	}

	err = createEtcdService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(etcdServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:38,代碼來源:etcd.go

示例9: Setup

func Setup(fsClient *fs.FsClient, systemdClient *systemd.SystemdClient) error {
	vLogger("\n# call ip6tables.Setup()")

	if err := setupRules(fsClient); err != nil {
		return maskAny(err)
	}

	if err := setupService(fsClient); err != nil {
		return maskAny(err)
	}

	if err := systemdClient.Reload(); err != nil {
		return maskAny(err)
	}

	for _, s := range services {
		if err := systemdClient.Start(s); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:23,代碼來源:ip6tables.go

示例10: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, distributionPath, overlayWorkdir, overlayMountPoint string) error {
	vLogger("\n# call overlay.Setup()")

	if err := fsc.MkdirAll(overlayWorkdir, fileMode); err != nil {
		return maskAny(err)
	}

	opts := struct {
		OverlayUpperdir string
		OverlayWorkdir  string
		MountPoint      string
	}{
		distributionPath,
		overlayWorkdir,
		overlayMountPoint,
	}

	b, err := templates.Render(overlayMountTemplate, opts)
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(overlayMountPath, b.Bytes(), fileMode); err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if err := sc.Start(overlayMount); err != nil {
		return maskAny(err)
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:36,代碼來源:overlay.go

示例11: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, rktVersion string, startDaemon, useOverlay bool) error {
	vLogger("\n# call rkt.Setup()")

	rktRaw, err := fc.Get("rkt/" + rktVersion + "/rkt")
	if err != nil {
		return maskAny(err)
	}

	if err := fsc.Write(distributionPath+"/rkt", rktRaw, binaryFileMode); err != nil {
		return maskAny(err)
	}

	err = createRktGarbageService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	err = createRktMetadataService(fsc, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if startDaemon {
		if err := sc.Start(rktGarbageTimerName); err != nil {
			return maskAny(err)
		}
		if err := sc.Start(rktMetadataServiceName); err != nil {
			return maskAny(err)
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:37,代碼來源:rkt.go

示例12: Setup

func Setup(fsc *fs.FsClient, sc *systemd.SystemdClient, fc fetchclient.FetchClient, distributionPath, dockerVersion string, privateRegistry []string, useIPTables, restartDaemon bool, useOverlay bool) error {
	vLogger("\n# call docker.Setup()")

	// This is the version where Docker split into multiple binaries.
	dockerMultipleBinariesVersion, _ := semver.NewVersion("1.11.0")

	semverDockerVersion, err := semver.NewVersion(dockerVersion)
	if err != nil {
		return maskAny(err)
	}

	dockerBinariesToGetAndWrite := []string{}
	if semverDockerVersion.LessThan(*dockerMultipleBinariesVersion) {
		dockerBinariesToGetAndWrite = []string{"docker"}
	} else {
		dockerBinariesToGetAndWrite = []string{
			"docker",
			"docker-containerd",
			"docker-containerd-ctr",
			"docker-containerd-shim",
			"docker-runc",
		}
	}

	for _, dockerBinaryName := range dockerBinariesToGetAndWrite {
		dockerRaw, err := fc.Get("docker/" + dockerVersion + "/" + dockerBinaryName)
		if err != nil {
			return maskAny(err)
		}

		if err := fsc.Write(distributionPath+"/"+dockerBinaryName, dockerRaw, fileMode); err != nil {
			return maskAny(err)
		}
	}

	err = createDockerService(fsc, dockerVersion, privateRegistry, useIPTables, useOverlay)
	if err != nil {
		return maskAny(err)
	}

	dockerTcpSocket, err := templates.Asset(socketTemplate)
	if err != nil {
		return maskAny(err)
	}

	// write docker-tcp.socket unit to host
	if err := fsc.Write(socketPath, dockerTcpSocket, fileMode); err != nil {
		return maskAny(err)
	}

	// reload unit files, that is, `systemctl daemon-reload`
	if err := sc.Reload(); err != nil {
		return maskAny(err)
	}

	if restartDaemon {
		// start docker-tcp.socket unit
		if err := sc.Start(socketName); err != nil {
			return maskAny(err)
		}

		// start docker.service unit
		if err := sc.Start(serviceName); err != nil {
			// If there is a dependency error, we just log it. This only happens in case
			// the provisioner is restarted. Then systemd throws an error when starting
			// docker, even though the only dependency (docker-tcp.socket) does not
			// fail.
			if systemd.IsJobDependency(err) {
				vLogger(err.Error())
			} else {
				return maskAny(err)
			}
		}
	}

	return nil
}
開發者ID:giantswarm,項目名稱:yochu,代碼行數:77,代碼來源:docker.go


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