Skip to content

Commit

Permalink
fix: restart containers if fatality occurs (#320)
Browse files Browse the repository at this point in the history
Signed-off-by: failfmi <[email protected]>
  • Loading branch information
failfmi authored Oct 26, 2021
1 parent 052f602 commit 226d010
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
6 changes: 2 additions & 4 deletions app/process/watcher/evm/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ func (ew *Watcher) listenForEvents(q qi.Queue) {

burnSubscription, err := ew.contracts.WatchBurnEventLogs(nil, burnEvents)
if err != nil {
ew.logger.Errorf("Failed to subscribe for Burn Event Logs for contract address [%s]. Error [%s].", ew.contracts.Address(), err)
return
ew.logger.Fatalf("Failed to subscribe for Burn Event Logs for contract address [%s]. Error [%s].", ew.contracts.Address(), err)
}

lockEvents := make(chan *router.RouterLock)
lockSubscription, err := ew.contracts.WatchLockEventLogs(nil, lockEvents)
if err != nil {
ew.logger.Errorf("Failed to subscribe for Lock Event Logs for contract address [%s]. Error [%s].", ew.contracts.Address(), err)
return
ew.logger.Fatalf("Failed to subscribe for Lock Event Logs for contract address [%s]. Error [%s].", ew.contracts.Address(), err)
}

for {
Expand Down
16 changes: 0 additions & 16 deletions app/process/watcher/evm/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/hashgraph/hedera-sdk-go/v2"
Expand Down Expand Up @@ -507,21 +506,6 @@ func Test_HandleLockLog_GetBlockTimestamp_Fails(t *testing.T) {
mocks.MQueue.AssertNotCalled(t, "Push", mock.Anything)
}

func Test_ListenForEvents_BurnSubscription_Fails(t *testing.T) {
setup()
var opts *bind.WatchOpts = nil
mocks.MBridgeContractService.On("WatchBurnEventLogs", opts, mock.Anything).Return(nil, errors.New("some-error"))
w.listenForEvents(mocks.MQueue)
}

func Test_ListenForEvents_LockSubscription_Fails(t *testing.T) {
setup()
var opts *bind.WatchOpts = nil
mocks.MBridgeContractService.On("WatchBurnEventLogs", opts, mock.Anything).Return(nil, nil)
mocks.MBridgeContractService.On("WatchLockEventLogs", opts, mock.Anything).Return(nil, errors.New("some-error"))
w.listenForEvents(mocks.MQueue)
}

func Test_HandleBurnLog_Token_Not_Supported(t *testing.T) {
setup()
mocks.MEVMClient.On("ChainID", context.Background()).Return(big.NewInt(33), nil)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.3"
services:
db:
image: postgres:9.6-alpine
restart: unless-stopped
restart: always
stop_grace_period: 2m
stop_signal: SIGTERM
tty: true
Expand All @@ -19,7 +19,7 @@ services:
image: gcr.io/hedera-eth-bridge-test/hedera-eth-bridge-validator:latest
environment:
VALIDATOR_DATABASE_HOST: db
restart: unless-stopped
restart: always
tty: true
volumes:
- ./bridge.yml:/src/hedera-eth-bridge-validator/config/bridge.yml
Expand Down
16 changes: 8 additions & 8 deletions examples/three-validators/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.3"
services:
alice_db:
image: postgres:9.6-alpine
restart: unless-stopped
restart: always
stop_grace_period: 2m
stop_signal: SIGTERM
tty: true
Expand All @@ -17,7 +17,7 @@ services:
- 6432:5432
bob_db:
image: postgres:9.6-alpine
restart: unless-stopped
restart: always
stop_grace_period: 2m
stop_signal: SIGTERM
tty: true
Expand All @@ -32,7 +32,7 @@ services:
- 7432:5432
carol_db:
image: postgres:9.6-alpine
restart: unless-stopped
restart: always
stop_grace_period: 2m
stop_signal: SIGTERM
tty: true
Expand All @@ -47,7 +47,7 @@ services:
- 8432:5432
dave_db:
image: postgres:9.6-alpine
restart: unless-stopped
restart: always
stop_grace_period: 2m
stop_signal: SIGTERM
tty: true
Expand All @@ -70,7 +70,7 @@ services:
volumes:
- ./bridge.yml:/src/hedera-eth-bridge-validator/config/bridge.yml
- ./alice/config/node.yml:/src/hedera-eth-bridge-validator/config/node.yml
restart: unless-stopped
restart: always
tty: true
ports:
- 6200:5200
Expand All @@ -83,7 +83,7 @@ services:
volumes:
- ./bridge.yml:/src/hedera-eth-bridge-validator/config/bridge.yml
- ./bob/config/node.yml:/src/hedera-eth-bridge-validator/config/node.yml
restart: unless-stopped
restart: always
tty: true
ports:
- 7200:5200
Expand All @@ -96,7 +96,7 @@ services:
volumes:
- ./bridge.yml:/src/hedera-eth-bridge-validator/config/bridge.yml
- ./carol/config/node.yml:/src/hedera-eth-bridge-validator/config/node.yml
restart: unless-stopped
restart: always
tty: true
ports:
- 8200:5200
Expand All @@ -109,7 +109,7 @@ services:
volumes:
- ./bridge.yml:/src/hedera-eth-bridge-validator/config/bridge.yml
- ./dave/config/node.yml:/src/hedera-eth-bridge-validator/config/node.yml
restart: unless-stopped
restart: always
tty: true
ports:
- 9200:5200
Expand Down

0 comments on commit 226d010

Please sign in to comment.