mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
RPC refactor to separate core from core_client and the rest of RPC.
Other random changes.
This commit is contained in:
@ -8,18 +8,20 @@ import (
|
||||
"runtime/debug"
|
||||
"time"
|
||||
|
||||
"github.com/tendermint/tendermint/alert"
|
||||
"github.com/tendermint/tendermint/binary"
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
)
|
||||
|
||||
func StartHTTPServer() {
|
||||
initHandlers()
|
||||
|
||||
log.Info(Fmt("Starting RPC HTTP server on %s", config.App().GetString("RPC.HTTP.ListenAddr")))
|
||||
func StartHTTPServer(listenAddr string, funcMap map[string]*RPCFunc) {
|
||||
log.Info(Fmt("Starting RPC HTTP server on %s", listenAddr))
|
||||
mux := http.NewServeMux()
|
||||
RegisterRPCFuncs(mux, funcMap)
|
||||
go func() {
|
||||
log.Crit("RPC HTTPServer stopped", "result", http.ListenAndServe(config.App().GetString("RPC.HTTP.ListenAddr"), RecoverAndLogHandler(http.DefaultServeMux)))
|
||||
res := http.ListenAndServe(
|
||||
listenAddr,
|
||||
RecoverAndLogHandler(mux),
|
||||
)
|
||||
log.Crit("RPC HTTPServer stopped", "result", res)
|
||||
}()
|
||||
}
|
||||
|
||||
@ -97,12 +99,3 @@ func (w *ResponseWriterWrapper) WriteHeader(status int) {
|
||||
w.Status = status
|
||||
w.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
// Stick it as a deferred statement in gouroutines to prevent the program from crashing.
|
||||
func Recover(daemonName string) {
|
||||
if e := recover(); e != nil {
|
||||
stack := string(debug.Stack())
|
||||
errorString := fmt.Sprintf("[%s] %s\n%s", daemonName, e, stack)
|
||||
alert.Alert(errorString)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user