fix: 修复编译二进制 Ctrl+C 无法退出的问题
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { closeDB } from '@/server/db'
|
||||
|
||||
export default () => {
|
||||
if (import.meta.dev) return
|
||||
|
||||
let exiting = false
|
||||
|
||||
const shutdown = async () => {
|
||||
if (exiting) {
|
||||
process.exit(0)
|
||||
}
|
||||
exiting = true
|
||||
|
||||
// Brief delay to let srvx close the HTTP server first
|
||||
setTimeout(async () => {
|
||||
await closeDB()
|
||||
process.exit(0)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
process.on('SIGINT', shutdown)
|
||||
process.on('SIGTERM', shutdown)
|
||||
}
|
||||
Reference in New Issue
Block a user