File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ const attachExitHandler = async ( callback ) => {
2+ process . once ( 'cleanup' , async ( ) => {
3+ await callback ( ) ;
4+ } ) ;
5+ process . once ( 'exit' , async ( ) => {
6+ process . emit ( 'cleanup' ) ;
7+ } ) ;
8+ process . on ( 'SIGINT' , async ( ) => {
9+ process . emit ( 'cleanup' ) ;
10+ } ) ;
11+ process . on ( 'SIGTERM' , async ( ) => {
12+ process . emit ( 'cleanup' ) ;
13+ } ) ;
14+ process . on ( 'uncaughtException' , async ( ) => {
15+ process . emit ( 'cleanup' ) ;
16+ } ) ;
17+ } ;
18+
19+ export { attachExitHandler } ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @thinkdeep/attach-exit-handler" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Attaches exit handling callback to termination signals." ,
5+ "main" : " attach-exit-handler.mjs" ,
6+ "scripts" : {
7+ "test" : " echo \" Error: no test specified\" && exit 1"
8+ },
9+ "type" : " module" ,
10+ "repository" : {
11+ "type" : " git" ,
12+ "url" : " git+https://github.com/ThinkDeepTech/attach-exit-handler.git"
13+ },
14+ "keywords" : [
15+ " Node"
16+ ],
17+ "author" : " Hayden McParlane" ,
18+ "license" : " ISC" ,
19+ "bugs" : {
20+ "url" : " https://github.com/ThinkDeepTech/attach-exit-handler/issues"
21+ },
22+ "homepage" : " https://github.com/ThinkDeepTech/attach-exit-handler#readme"
23+ }
You can’t perform that action at this time.
0 commit comments