-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
listen and provide callback handler on SIGPIPE signal
- Loading branch information
1 parent
713f2e4
commit ab54a69
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Logs # | ||
/logs | ||
*.log | ||
*.log* | ||
|
||
# Node files # | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# OS generated files # | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Typing # | ||
typings/ | ||
|
||
# Dist # | ||
dist/ | ||
|
||
# IDE # | ||
.idea/ | ||
*.swp | ||
.awcache | ||
|
||
# Generated source-code # | ||
src/**/*.js.map | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs # | ||
/logs | ||
*.log | ||
*.log* | ||
|
||
# Node files # | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
# OS generated files # | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Typing # | ||
typings/ | ||
|
||
# IDE # | ||
.idea/ | ||
*.swp | ||
.awcache | ||
|
||
# Generated source-code # | ||
test/ | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
let cbToCall; | ||
const process = global.process | ||
|
||
const isProcessOk = (process) => { | ||
return process && | ||
typeof process === 'object' && | ||
typeof process.kill === 'function' && | ||
typeof process.pid === 'number' && | ||
typeof process.on === 'function' | ||
} | ||
|
||
const reloadCbFn = (cb) => { | ||
cbToCall = cb; | ||
}; | ||
|
||
process.on('SIGPIPE', () => { | ||
if (typeof cbToCall === 'function') { | ||
cbToCall(); | ||
} else { | ||
console.error('SIGPIPE triggered but no callback provided to execute!'); | ||
} | ||
}); | ||
|
||
if (!isProcessOk(process)) { | ||
module.exports = () => { | ||
return () => {} | ||
} | ||
} else { | ||
module.exports = reloadCbFn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "runtime-node-refresh", | ||
"version": "1.0.0", | ||
"description": "Refresh node environment variables on runtime without restarting the node server.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/przemek-nowicki/runtime-node-refresh.git" | ||
}, | ||
"keywords": [ | ||
"refresh", | ||
"env", | ||
"update", | ||
"env", | ||
"runtime", | ||
"refresh", | ||
"node", | ||
"refresh", | ||
"envs" | ||
], | ||
"author": "[email protected]", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/przemek-nowicki/runtime-node-refresh/issues" | ||
}, | ||
"homepage": "https://github.com/przemek-nowicki/runtime-node-refresh#readme" | ||
} |