1 Star 0 Fork 3

flyseaskying/blockchain-explorer

forked from ezpod/blockchain-explorer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
sync.js 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
Atsushin 提交于 2019-12-26 13:12 +08:00 . Be 720 update log4js (#72)
/**
* SPDX-License-Identifier: Apache-2.0
*/
const Synchronizer = require('./app/Synchronizer');
const helper = require('./app/common/helper');
const logger = helper.getLogger('Sync');
const ExplorerError = require('./app/common/ExplorerError');
const args = process.argv.slice(2);
let synchronizer;
async function start() {
logger.debug('Start synchronizer');
synchronizer = new Synchronizer(args);
await synchronizer.initialize();
logger.info(`Synchronizer pid is ${process.pid}`);
}
start();
/*
* This function is called when you want the server to die gracefully
* i.e. wait for existing connections
*/
const shutDown = function() {
logger.info(
'<<<<<<<<<<<<<<<<<<<<<<<<<< Closing client processor >>>>>>>>>>>>>>>>>>>>>'
);
if (synchronizer) {
synchronizer.close();
}
setTimeout(() => {
process.exit(0);
setTimeout(() => {
logger.error(
'Could not close child connections in time, forcefully shutting down'
);
if (synchronizer) {
synchronizer.close();
}
process.exit(1);
}, 5000);
}, 2000);
};
process.on('unhandledRejection', up => {
logger.error(
'<<<<<<<<<<<<<<<<<<<<<<<<<< Synchronizer Error >>>>>>>>>>>>>>>>>>>>>'
);
if (up instanceof ExplorerError) {
logger.error('Error : ', up.message);
} else {
logger.error(up);
}
shutDown();
});
process.on('uncaughtException', up => {
logger.error(
'<<<<<<<<<<<<<<<<<<<<<<<<<< Synchronizer Error >>>>>>>>>>>>>>>>>>>>>'
);
if (up instanceof ExplorerError) {
logger.error('Error : ', up.message);
} else {
logger.error(up);
}
shutDown();
});
// Listen for TERM signal .e.g. kill
process.on('SIGTERM', shutDown);
// Listen for INT signal e.g. Ctrl-C
process.on('SIGINT', shutDown);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flyseaskying/hyperledger-blockchain-explorer.git
git@gitee.com:flyseaskying/hyperledger-blockchain-explorer.git
flyseaskying
hyperledger-blockchain-explorer
blockchain-explorer
master

搜索帮助