upgrades to debora/barak to allow shutting down barak

This commit is contained in:
Jae Kwon
2015-07-07 19:26:33 -07:00
parent 1f34236948
commit 53a1cd2fbf
5 changed files with 57 additions and 2 deletions

View File

@ -106,12 +106,12 @@ func main() {
},
cli.Command{
Name: "open",
Usage: "open listener",
Usage: "open barak listener",
Action: cliOpenListener,
},
cli.Command{
Name: "close",
Usage: "close listener",
Usage: "close barka listener",
Action: cliCloseListener,
},
cli.Command{
@ -119,6 +119,11 @@ func main() {
Usage: "download file <remote-path> <local-path-prefix>",
Action: cliDownloadFile,
},
cli.Command{
Name: "quit",
Usage: "quit barak",
Action: cliQuit,
},
}
app.Run(os.Args)
}
@ -330,3 +335,21 @@ func cliDownloadFile(c *cli.Context) {
}
wg.Wait()
}
func cliQuit(c *cli.Context) {
command := btypes.CommandQuit{}
wg := sync.WaitGroup{}
for _, remote := range Config.Remotes {
wg.Add(1)
go func(remote string) {
defer wg.Done()
response, err := Quit(Config.PrivKey, remote, command)
if err != nil {
fmt.Printf("%v failure. %v\n", remote, err)
} else {
fmt.Printf("%v success. %v\n", remote, response)
}
}(remote)
}
wg.Wait()
}