Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 66bc4e1

Browse files
committed
feat: add SIGTERM handler for go-ipfs compatibility
1 parent 5691fa0 commit 66bc4e1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/cli/commands/daemon.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ module.exports = {
4040
print('Daemon is ready')
4141
})
4242

43-
process.on('SIGINT', () => {
44-
print('Received interrupt signal, shutting down..')
43+
const cleanup = (code) => {
44+
print(`Received ${code} signal, shutting down..`)
4545
httpAPI.stop((err) => {
4646
if (err) {
4747
throw err
4848
}
49-
process.exit(0)
49+
process.exit(code)
5050
})
51-
})
51+
}
52+
53+
// listen for graceful termination
54+
process.on('SIGTERM', cleanup)
55+
process.on('SIGINT', cleanup)
5256
}
5357
}

0 commit comments

Comments
 (0)