Skip to content

Commit

Permalink
relayer: graceful stopping
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlee42 committed Mar 22, 2024
1 parent 8a20ac0 commit bc8f591
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/message-relayer/src/exec/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ const main = async () => {
} else {
throw new Error('Must pass one of L1_WALLET_KEY or MNEMONIC')
}
var chainId = L2_NODE_CHAIN_ID
if (!chainId || chainId == 0) {
chainId = await l2Provider.send('eth_chainId', [])
let l2ChainId = L2_NODE_CHAIN_ID
if (!l2ChainId) {
const network = await l2Provider.getNetwork()
l2ChainId = network.chainId
}
const service = new MessageRelayerService({
l1RpcProvider: l1Provider,
l2RpcProvider: l2Provider,
l2ChainId: chainId,
l2ChainId,
addressManagerAddress: ADDRESS_MANAGER_ADDRESS,
l1Wallet: wallet,
relayGasLimit: RELAY_GAS_LIMIT,
Expand All @@ -128,6 +129,14 @@ const main = async () => {
relayNumber: RELAY_NUMBER,
})

const stop = async (signal) => {
console.log(`"{"msg": "${signal} - Stopping message relayer"}"`)
await service.stop()
}

process.on('SIGTERM', stop)
process.on('SIGINT', stop)

await service.start()
}
export default main

0 comments on commit bc8f591

Please sign in to comment.