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


Golang runtime.ServiceRuntime类代码示例

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


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

示例1: AppDeploy

func AppDeploy(configStore *config.Store, serviceRuntime *runtime.ServiceRuntime, app, env, version string) error {
	log.Printf("Pulling image %s...", version)

	image, err := serviceRuntime.PullImage(version, "")
	if image == nil || err != nil {
		return fmt.Errorf("unable to pull %s. Has it been released yet?", version)
	}

	svcCfg, err := configStore.GetApp(app, env)
	if err != nil {
		return fmt.Errorf("unable to deploy app: %s.", err)
	}

	if svcCfg == nil {
		return fmt.Errorf("app %s does not exist. Create it first.", app)
	}

	svcCfg.SetVersion(version)
	svcCfg.SetVersionID(utils.StripSHA(image.ID))

	updated, err := configStore.UpdateApp(svcCfg, env)
	if err != nil {
		return fmt.Errorf("could not store version: %s", err)
	}
	if !updated {
		return fmt.Errorf("%s NOT deployed.", version)
	}
	log.Printf("Deployed %s.\n", version)
	return nil
}
开发者ID:carriercomm,项目名称:galaxy,代码行数:30,代码来源:app.go

示例2: RegisterAll

func RegisterAll(serviceRuntime *runtime.ServiceRuntime, configStore *config.Store, env, pool, hostIP, shuttleAddr string, loggedOnce bool) {
	columns := []string{"CONTAINER ID | IMAGE | EXTERNAL | INTERNAL | CREATED | EXPIRES"}

	registrations, err := serviceRuntime.RegisterAll(env, pool, hostIP)
	if err != nil {
		log.Errorf("ERROR: Unable to register containers: %s", err)
		return
	}

	fn := log.Debugf
	if !loggedOnce {
		fn = log.Printf
	}

	for _, registration := range registrations {
		if !loggedOnce || time.Now().Unix()%60 < 10 {
			fn("Registered %s running as %s for %s%s", strings.TrimPrefix(registration.ContainerName, "/"),
				registration.ContainerID[0:12], registration.Name, locationAt(registration))
		}

		columns = append(columns, strings.Join([]string{
			registration.ContainerID[0:12],
			registration.Image,
			registration.ExternalAddr(),
			registration.InternalAddr(),
			utils.HumanDuration(time.Now().Sub(registration.StartedAt)) + " ago",
			"In " + utils.HumanDuration(registration.Expires.Sub(time.Now().UTC())),
		}, " | "))

	}

	registerShuttle(configStore, env, shuttleAddr)
}
开发者ID:zombor,项目名称:galaxy,代码行数:33,代码来源:discovery.go

示例3: AppShell

func AppShell(configStore *config.Store, serviceRuntime *runtime.ServiceRuntime, app, env, pool string) error {
	appCfg, err := configStore.GetApp(app, env)
	if err != nil {
		return fmt.Errorf("unable to run command: %s.", err)
	}

	err = serviceRuntime.StartInteractive(env, pool, appCfg)
	if err != nil {
		return fmt.Errorf("could not start container: %s", err)
	}
	return nil
}
开发者ID:carriercomm,项目名称:galaxy,代码行数:12,代码来源:app.go

示例4: Status

func Status(serviceRuntime *runtime.ServiceRuntime, configStore *config.Store, env, pool, hostIP string) error {

	containers, err := serviceRuntime.ManagedContainers()
	if err != nil {
		panic(err)
	}

	//FIXME: addresses, port, and expires missing in output
	columns := []string{
		"APP | CONTAINER ID | IMAGE | EXTERNAL | INTERNAL | PORT | CREATED | EXPIRES"}

	for _, container := range containers {
		name := serviceRuntime.EnvFor(container)["GALAXY_APP"]
		registered, err := configStore.GetServiceRegistration(
			env, pool, hostIP, container)
		if err != nil {
			return err
		}

		if registered != nil {
			columns = append(columns,
				strings.Join([]string{
					registered.Name,
					registered.ContainerID[0:12],
					registered.Image,
					registered.ExternalAddr(),
					registered.InternalAddr(),
					registered.Port,
					utils.HumanDuration(time.Now().UTC().Sub(registered.StartedAt)) + " ago",
					"In " + utils.HumanDuration(registered.Expires.Sub(time.Now().UTC())),
				}, " | "))

		} else {
			columns = append(columns,
				strings.Join([]string{
					name,
					container.ID[0:12],
					container.Image,
					"",
					"",
					"",
					utils.HumanDuration(time.Now().Sub(container.Created)) + " ago",
					"",
				}, " | "))
		}

	}

	result, _ := columnize.SimpleFormat(columns)
	log.Println(result)
	return nil
}
开发者ID:zombor,项目名称:galaxy,代码行数:52,代码来源:discovery.go

示例5: AppRun

func AppRun(configStore *config.Store, serviceRuntime *runtime.ServiceRuntime, app, env string, args []string) error {
	appCfg, err := configStore.GetApp(app, env)
	if err != nil {
		return fmt.Errorf("unable to run command: %s.", err)

	}

	_, err = serviceRuntime.RunCommand(env, appCfg, args)
	if err != nil {
		return fmt.Errorf("could not start container: %s", err)
	}
	return nil
}
开发者ID:carriercomm,项目名称:galaxy,代码行数:13,代码来源:app.go

示例6: Register

func Register(serviceRuntime *runtime.ServiceRuntime, configStore *config.Store, env, pool, hostIP, shuttleAddr string) {
	if shuttleAddr != "" {
		client = shuttle.NewClient(shuttleAddr)
	}

	RegisterAll(serviceRuntime, configStore, env, pool, hostIP, shuttleAddr, false)

	containerEvents := make(chan runtime.ContainerEvent)
	err := serviceRuntime.RegisterEvents(env, pool, hostIP, containerEvents)
	if err != nil {
		log.Printf("ERROR: Unable to register docker event listener: %s", err)
	}

	for {

		select {
		case ce := <-containerEvents:
			switch ce.Status {
			case "start":
				reg, err := configStore.RegisterService(env, pool, hostIP, ce.Container)
				if err != nil {
					log.Errorf("ERROR: Unable to register container: %s", err)
					continue
				}

				log.Printf("Registered %s running as %s for %s%s", strings.TrimPrefix(reg.ContainerName, "/"),
					reg.ContainerID[0:12], reg.Name, locationAt(reg))
				registerShuttle(configStore, env, shuttleAddr)
			case "die", "stop":
				reg, err := configStore.UnRegisterService(env, pool, hostIP, ce.Container)
				if err != nil {
					log.Errorf("ERROR: Unable to unregister container: %s", err)
					continue
				}

				if reg != nil {
					log.Printf("Unregistered %s running as %s for %s%s", strings.TrimPrefix(reg.ContainerName, "/"),
						reg.ContainerID[0:12], reg.Name, locationAt(reg))
				}
				RegisterAll(serviceRuntime, configStore, env, pool, hostIP, shuttleAddr, true)
				pruneShuttleBackends(configStore, env, shuttleAddr)
			}

		case <-time.After(10 * time.Second):
			RegisterAll(serviceRuntime, configStore, env, pool, hostIP, shuttleAddr, true)
			pruneShuttleBackends(configStore, env, shuttleAddr)
		}
	}
}
开发者ID:zombor,项目名称:galaxy,代码行数:49,代码来源:discovery.go

示例7: Unregister

func Unregister(serviceRuntime *runtime.ServiceRuntime, configStore *config.Store,
	env, pool, hostIP, shuttleAddr string) {
	unregisterShuttle(configStore, env, hostIP, shuttleAddr)
	serviceRuntime.UnRegisterAll(env, pool, hostIP)
	os.Exit(0)
}
开发者ID:zombor,项目名称:galaxy,代码行数:6,代码来源:discovery.go


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