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


Golang mongo.RemoveService函數代碼示例

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


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

示例1: uninstallAgent

func (a *MachineAgent) uninstallAgent(agentConfig agent.Config) error {
	var errors []error
	agentServiceName := agentConfig.Value(agent.AgentServiceName)
	if agentServiceName == "" {
		// For backwards compatibility, handle lack of AgentServiceName.
		agentServiceName = os.Getenv("UPSTART_JOB")
	}
	if agentServiceName != "" {
		if err := service.NewService(agentServiceName, common.Conf{}).Remove(); err != nil {
			errors = append(errors, fmt.Errorf("cannot remove service %q: %v", agentServiceName, err))
		}
	}
	// Remove the juju-run symlink.
	if err := os.Remove(jujuRun); err != nil && !os.IsNotExist(err) {
		errors = append(errors, err)
	}

	namespace := agentConfig.Value(agent.Namespace)
	if err := mongo.RemoveService(namespace); err != nil {
		errors = append(errors, fmt.Errorf("cannot stop/remove mongo service with namespace %q: %v", namespace, err))
	}
	if err := os.RemoveAll(agentConfig.DataDir()); err != nil {
		errors = append(errors, err)
	}
	if len(errors) == 0 {
		return nil
	}
	return fmt.Errorf("uninstall failed: %v", errors)
}
開發者ID:zhouqt,項目名稱:juju,代碼行數:29,代碼來源:machine.go

示例2: TestRemoveService

func (s *MongoSuite) TestRemoveService(c *gc.C) {
	err := mongo.RemoveService("namespace")
	c.Assert(err, gc.IsNil)
	c.Assert(s.removed, jc.DeepEquals, []upstart.Service{{
		Name: "juju-db-namespace",
		Conf: common.Conf{InitDir: upstart.InitDir},
	}})
}
開發者ID:kapilt,項目名稱:juju,代碼行數:8,代碼來源:mongo_test.go

示例3: TestRemoveService

func (s *MongoSuite) TestRemoveService(c *gc.C) {
	s.data.SetStatus(mongo.ServiceName, "running")

	err := mongo.RemoveService()
	c.Assert(err, jc.ErrorIsNil)

	removed := s.data.Removed()
	if !c.Check(removed, gc.HasLen, 1) {
		c.Check(removed[0].Name(), gc.Equals, "juju-db-namespace")
		c.Check(removed[0].Conf(), jc.DeepEquals, common.Conf{})
	}
	s.data.CheckCallNames(c, "Stop", "Remove")
}
開發者ID:xushiwei,項目名稱:juju,代碼行數:13,代碼來源:mongo_test.go

示例4: OpenPorts

		// os.IsNotExist error isn't always returned.
		if _, statErr := os.Stat(env.config.rootDir()); os.IsNotExist(statErr) {
			return nil
		}
		return err
	}
	return nil
}

type agentService interface {
	Stop() error
	Remove() error
}

var mongoRemoveService = func(namespace string) error {
	return mongo.RemoveService(namespace)
}

var discoverService = func(name string) (agentService, error) {
	return service.DiscoverService(name, servicecommon.Conf{})
}

// OpenPorts is specified in the Environ interface.
func (env *localEnviron) OpenPorts(ports []network.PortRange) error {
	return fmt.Errorf("open ports not implemented")
}

// ClosePorts is specified in the Environ interface.
func (env *localEnviron) ClosePorts(ports []network.PortRange) error {
	return fmt.Errorf("close ports not implemented")
}
開發者ID:imoapps,項目名稱:juju,代碼行數:31,代碼來源:environ.go


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