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

@ -22,6 +22,8 @@ import (
"github.com/tendermint/tendermint/rpc/server"
)
const BarakVersion = "0.0.1"
var Routes map[string]*rpcserver.RPCFunc
func init() {
@ -72,6 +74,7 @@ func Status() (*ResponseStatus, error) {
barak_.mtx.Unlock()
return &ResponseStatus{
Version: BarakVersion,
Pid: pid,
Nonce: nonce,
Validators: validators,
@ -96,6 +99,8 @@ func Run(authCommand AuthCommand) (interface{}, error) {
return OpenListener(c.Addr)
case CommandCloseListener:
return CloseListener(c.Addr)
case CommandQuit:
return Quit()
default:
return nil, errors.New("Invalid endpoint for command")
}
@ -204,6 +209,15 @@ func CloseListener(addr string) (*ResponseCloseListener, error) {
return &ResponseCloseListener{}, nil
}
func Quit() (*ResponseQuit, error) {
fmt.Println("Barak shutting down due to Quit()")
go func() {
time.Sleep(time.Second)
os.Exit(0)
}()
return &ResponseQuit{}, nil
}
//--------------------------------------------------------------------------------
// Another barak instance registering its external