停止节点服务器后从节点服务器/index.js 运行 bash 脚本

时间:2021-03-27 16:16:26

标签: javascript node.js docker

我想运行的脚本只会停止并清除容器。

我已经试过了:

process.on('exit', function(code) {
  console.log(`Tearing down containers`);
  shell.exec('./stop_ctn.sh')
});

app.listen( app.get( 'port' ), function(){
  console.log( 'Express server listening on port ' + app.get( 'port' ));
})

这会引发此错误:

Elasticsearch ERROR: 2021-03-27T16:11:45Z
  Error: Request error, retrying
  HEAD http://localhost:9700/ => connect ECONNREFUSED 127.0.0.1:9700

在它抛出该错误后,有时我可以访问 elasticsearch 容器,有时则不能。

试图找到一种在节点服务器停止后执行脚本的方法。

0 个答案:

没有答案