func main() { disco = discoclient.NewClient("/var/run/disco.sock") root := &commando.Command{ Name: "disco", Description: "A Container Network Discovery tool", } link = &commando.Command{ Name: "link", Description: "Link containers together", Execute: linkContainers, } link.AddOption("targets", "The target container(s) [NAME=container:port]", true, "-t", "--target") link.AddOption("image", "Image to create linked container from", true, "-i", "--image") link.AddOption("name", "Name to give linked container", true, "-n", "--name") root.AddSubCommand(link) nodeId := &commando.Command{ Name: "node-id", Description: "Get Disco Node Id", Execute: getNodeId, } root.AddSubCommand(nodeId) list := &commando.Command{ Name: "list", Description: "List Disco-managed Containers", Execute: listContainers, } root.AddSubCommand(list) root.Parse() }
func init() { err := LoadConfig() if err != nil { log.Fatalf(err.Error()) } o := &p.ControllerOptions{ Nodes: config.Persist.Nodes, Type: config.Persist.Type, } persist, err := p.NewController(o) if err != nil { log.Fatalf(err.Error()) } createTree(persist) registerNode(persist) api, err = NewDiscoAPI(&ApiConfig{ Id: node.Id, DockerUri: config.Disco.DockerSocket, Persist: persist, }) if err != nil { log.Fatalf(err.Error()) } dc = discoclient.NewClient("/var/run/disco.sock") if err != nil { log.Fatalf(err.Error()) } sigc := make(chan os.Signal, 1) signal.Notify(sigc, os.Interrupt, syscall.SIGTERM) go func(c chan os.Signal) { sig := <-c log.Printf("%s Signal receieved: Exiting Disco Daemon", sig) api.Stop() os.Exit(0) }(sigc) }