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.

50 lines
1.2 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "github.com/tendermint/abci/example/dummy"
  6. "github.com/tendermint/abci/server"
  7. "github.com/tendermint/abci/types"
  8. cmn "github.com/tendermint/tmlibs/common"
  9. "github.com/tendermint/tmlibs/log"
  10. )
  11. func main() {
  12. addrPtr := flag.String("addr", "tcp://0.0.0.0:46658", "Listen address")
  13. abciPtr := flag.String("abci", "socket", "socket | grpc")
  14. persistencePtr := flag.String("persist", "", "directory to use for a database")
  15. flag.Parse()
  16. logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
  17. // Create the application - in memory or persisted to disk
  18. var app types.Application
  19. if *persistencePtr == "" {
  20. app = dummy.NewDummyApplication()
  21. } else {
  22. app = dummy.NewPersistentDummyApplication(*persistencePtr)
  23. app.(*dummy.PersistentDummyApplication).SetLogger(logger.With("module", "dummy"))
  24. }
  25. // Start the listener
  26. srv, err := server.NewServer(*addrPtr, *abciPtr, app)
  27. if err != nil {
  28. logger.Error(err.Error())
  29. os.Exit(1)
  30. }
  31. srv.SetLogger(logger.With("module", "abci-server"))
  32. if _, err := srv.Start(); err != nil {
  33. logger.Error(err.Error())
  34. os.Exit(1)
  35. }
  36. // Wait forever
  37. cmn.TrapSignal(func() {
  38. // Cleanup
  39. srv.Stop()
  40. })
  41. }