You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
581 B

package main
import (
"log"
"os"
"time"
"github.com/tncardoso/gocurses"
)
// End disconnects (from) all Peers and stops the process
func End(crash, reconnect bool) {
log.Print("Ending")
var reason uint8 = AccessDeniedShutdown
if crash {
reason = AccessDeniedCrash
}
for _, clt := range Conns() {
clt.CloseWith(reason, "", reconnect)
}
time.Sleep(time.Second)
rpcSrvMu.Lock()
for srv := range rpcSrvs {
srv.Close()
}
rpcSrvMu.Unlock()
Announce(AnnounceDelete)
log.Writer().(*Logger).Close()
gocurses.End()
if crash {
os.Exit(1)
}
os.Exit(0)
}