Skip to content

Commit bc8f591

Browse files
committed
relayer: graceful stopping
1 parent 8a20ac0 commit bc8f591

File tree

1 file changed

+13
-4
lines changed
  • packages/message-relayer/src/exec

1 file changed

+13
-4
lines changed

packages/message-relayer/src/exec/run.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,15 @@ const main = async () => {
106106
} else {
107107
throw new Error('Must pass one of L1_WALLET_KEY or MNEMONIC')
108108
}
109-
var chainId = L2_NODE_CHAIN_ID
110-
if (!chainId || chainId == 0) {
111-
chainId = await l2Provider.send('eth_chainId', [])
109+
let l2ChainId = L2_NODE_CHAIN_ID
110+
if (!l2ChainId) {
111+
const network = await l2Provider.getNetwork()
112+
l2ChainId = network.chainId
112113
}
113114
const service = new MessageRelayerService({
114115
l1RpcProvider: l1Provider,
115116
l2RpcProvider: l2Provider,
116-
l2ChainId: chainId,
117+
l2ChainId,
117118
addressManagerAddress: ADDRESS_MANAGER_ADDRESS,
118119
l1Wallet: wallet,
119120
relayGasLimit: RELAY_GAS_LIMIT,
@@ -128,6 +129,14 @@ const main = async () => {
128129
relayNumber: RELAY_NUMBER,
129130
})
130131

132+
const stop = async (signal) => {
133+
console.log(`"{"msg": "${signal} - Stopping message relayer"}"`)
134+
await service.stop()
135+
}
136+
137+
process.on('SIGTERM', stop)
138+
process.on('SIGINT', stop)
139+
131140
await service.start()
132141
}
133142
export default main

0 commit comments

Comments
 (0)