-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add oracle service for remote shutdown (#531)
- Loading branch information
1 parent
ae83c76
commit f95beee
Showing
16 changed files
with
248 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const baseConfig = require('./base.config') | ||
|
||
const { | ||
ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL, | ||
ORACLE_SHUTDOWN_SERVICE_URL, | ||
ORACLE_SHUTDOWN_CONTRACT_ADDRESS, | ||
ORACLE_SHUTDOWN_CONTRACT_METHOD | ||
} = process.env | ||
|
||
module.exports = { | ||
...baseConfig.bridgeConfig, | ||
id: 'shutdown-manager', | ||
name: 'shutdown-manager', | ||
pollingInterval: ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL || 120000, | ||
checksBeforeResume: 3, | ||
checksBeforeStop: 1, | ||
shutdownServiceURL: ORACLE_SHUTDOWN_SERVICE_URL, | ||
shutdownContractAddress: ORACLE_SHUTDOWN_CONTRACT_ADDRESS, | ||
shutdownMethod: (ORACLE_SHUTDOWN_CONTRACT_METHOD || 'isShutdown()').trim() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { redis } = require('./redisClient') | ||
|
||
let isShutdown = false | ||
async function getShutdownFlag(logger, shutdownKey, force = false) { | ||
if (force) { | ||
logger.debug('Reading current shutdown state from the DB') | ||
isShutdown = (await redis.get(shutdownKey)) === 'true' | ||
logger.debug({ isShutdown }, 'Read shutdown state from the DB') | ||
} | ||
return isShutdown | ||
} | ||
|
||
async function setShutdownFlag(logger, shutdownKey, value) { | ||
logger.info({ isShutdown: value }, 'Updating current shutdown state in the DB') | ||
isShutdown = value | ||
await redis.set(shutdownKey, value) | ||
logger.debug('Updated state in the DB') | ||
} | ||
|
||
module.exports = { | ||
getShutdownFlag, | ||
setShutdownFlag | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.