gpt4 book ai didi

mysql - 如何检测node js和mysql中的ctrl+c?

转载 作者:行者123 更新时间:2023-11-29 13:01:05 25 4
gpt4 key购买 nike

在我的node.js中我使用mysql。我为 mysql 连接保留一个全局变量,当我使用 ctrl+c 结束服务器或者服务器以某种方式断开连接时,我想执行connection.close() .

有人知道我该怎么做吗?

谢谢

最佳答案

process.on('SIGINT', function() { }); 适用于 Windows 和 *nix,并捕获按下 ctrl+c 时发送的信号。

关于mysql - 如何检测node js和mysql中的ctrl+c?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23329141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com