我正在使用eureka - js -客户端与eureka发现服务器对节点js应用程序进行筛选。效果很好。但是,当节点js服务关闭时,它不会取消发现,并且在服务关闭后仍然显示为可用的实例。
在这里,我如何取消注册:
process.on('exit', function() {
eurekaClient.stop() ;
});发布于 2020-06-21 07:07:15
我为节点js应用程序和eureka发现服务中的取消注册程序使用了exitHandelr。
process.stdin.resume();
function exitHandler(options, exitCode) {
if (options.cleanup) console.log('clean');
if (exitCode || exitCode === 0) console.log(exitCode);
if (options.exit) {
eurekaClient.stop(function (error) {
process.exit();
});
}
}
//do something when app is closing
process.on('exit', exitHandler.bind(null, {cleanup: true}));
//catches ctrl+c event
process.on('SIGINT', exitHandler.bind(null, {exit: true}));
// catches "kill pid" (for example: nodemon restart)
process.on('SIGUSR1', exitHandler.bind(null, {exit: true}));
process.on('SIGUSR2', exitHandler.bind(null, {exit: true}));
//catches uncaught exceptions
process.on('uncaughtException', exitHandler.bind(null, {exit: true}));https://stackoverflow.com/questions/62278824
复制相似问题