本文整理汇总了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)
}
示例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},
}})
}
示例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")
}
示例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")
}