From bd1544e8f43ecd23eb79d452c08e90b3018b78ea Mon Sep 17 00:00:00 2001 From: Sang Heon Lee Date: Mon, 1 Apr 2024 18:37:00 +0900 Subject: [PATCH] fix: interop-node startup bug (#144) --- tools/interop-node/cmd/start.go | 8 ++++++++ tools/interop-node/subscriber/ethereum_subscriber.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/interop-node/cmd/start.go b/tools/interop-node/cmd/start.go index de3a2e00..43d0c413 100644 --- a/tools/interop-node/cmd/start.go +++ b/tools/interop-node/cmd/start.go @@ -3,6 +3,9 @@ package cmd import ( "context" "fmt" + "os" + "os/signal" + "syscall" "github.com/tendermint/tendermint/libs/cli/flags" @@ -40,6 +43,11 @@ func startCmd() *cobra.Command { interopServer.Close() }() + cancelChan := make(chan os.Signal, 1) + signal.Notify(cancelChan, syscall.SIGTERM, syscall.SIGINT) + + <-cancelChan + return nil }, } diff --git a/tools/interop-node/subscriber/ethereum_subscriber.go b/tools/interop-node/subscriber/ethereum_subscriber.go index 5854b515..b6d6a2f9 100644 --- a/tools/interop-node/subscriber/ethereum_subscriber.go +++ b/tools/interop-node/subscriber/ethereum_subscriber.go @@ -204,6 +204,7 @@ func (sub *EthereumSubscriber) dbLoop(ctx context.Context) { case <-ctx.Done(): close(sub.dbCh) + return } } } @@ -235,7 +236,6 @@ func (sub *EthereumSubscriber) fetchLoop(ctx context.Context) { sub.dbCh <- event case <-ctx.Done(): sub.logger.Info("fetchLoop stopped") - close(sub.dbCh) return } }