tendermint/cmd/dummy/main.go

47 lines
1.1 KiB
Go
Raw Normal View History

2015-11-27 18:42:00 -05:00
package main
import (
2016-01-30 19:44:04 -08:00
"flag"
2017-04-28 00:37:18 +04:00
"os"
2016-01-30 19:44:04 -08:00
2017-01-12 15:47:55 -05:00
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
2017-04-21 18:25:13 -04:00
cmn "github.com/tendermint/tmlibs/common"
2017-04-28 00:37:18 +04:00
"github.com/tendermint/tmlibs/log"
2015-11-27 18:42:00 -05:00
)
func main() {
2016-01-30 19:44:04 -08:00
addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address")
2017-01-12 15:47:55 -05:00
abciPtr := flag.String("abci", "socket", "socket | grpc")
2016-08-24 01:42:57 -04:00
persistencePtr := flag.String("persist", "", "directory to use for a database")
2016-01-30 19:44:04 -08:00
flag.Parse()
2017-05-03 11:39:15 +04:00
logger := log.NewTMLogger(os.Stdout)
2017-04-28 00:37:18 +04:00
2016-08-24 01:42:57 -04:00
// Create the application - in memory or persisted to disk
var app types.Application
if *persistencePtr == "" {
app = dummy.NewDummyApplication()
} else {
app = dummy.NewPersistentDummyApplication(*persistencePtr)
2017-04-28 00:37:18 +04:00
app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy"))
2016-08-24 01:42:57 -04:00
}
2015-11-27 18:42:00 -05:00
// Start the listener
2017-01-12 15:47:55 -05:00
srv, err := server.NewServer(*addrPtr, *abciPtr, app)
2015-11-27 18:42:00 -05:00
if err != nil {
2017-05-01 16:43:52 +04:00
logger.Error(err.Error())
os.Exit(1)
2015-11-27 18:42:00 -05:00
}
2017-04-28 00:37:18 +04:00
srv.SetLogger(log.With(logger, "module", "abci-server"))
2015-11-27 18:42:00 -05:00
// Wait forever
2017-01-23 20:26:17 -08:00
cmn.TrapSignal(func() {
2015-11-27 18:42:00 -05:00
// Cleanup
2016-12-26 22:12:32 -08:00
srv.Stop()
2015-11-27 18:42:00 -05:00
})
}