-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add graceful shutdown and error handling #779
base: master
Are you sure you want to change the base?
Conversation
Currently not functional due to switch not working
Ready for review. |
bin/http-server
Outdated
@@ -60,12 +64,15 @@ if (argv.h || argv.help) { | |||
' --no-dotfiles Do not show dotfiles', | |||
' --mimetypes Path to a .types file for custom mimetype definition', | |||
' -h --help Print this list and exit.', | |||
' -v --version Print the version and exit.' | |||
' -v --version Print the version and exit.', | |||
' -n --no-panic If error occurs, gracefully shut down and create log file', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure -n
is an easy mnemonic here, would only having the long version available be sufficient?
bin/http-server
Outdated
let etime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '') | ||
console.log(colors.green(etime)) | ||
console.log(colors.red("Fatal error: ")+ e.code + ": "+e.message) | ||
let fname = ".httpserver-"+etime.split(" ")[0]+"-"+etime.split(" ")[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the log file, could we end it with .log
to make it clear what the file is?
Co-authored-by: Jade Michael Thornton <[email protected]>
@@ -57,6 +57,10 @@ Default file extension is none is provided. | |||
.BI \-s ", " \-\-silent | |||
Suppress log messages from output. | |||
|
|||
.TP | |||
.BI \-n ", " \-\-no-panic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the -n needs removing
var argv = require('minimist')(process.argv.slice(2), { | ||
alias: { | ||
tls: 'ssl' | ||
} | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank lines not needed
This PR adds handling for fatal crashes of any type. Just so you don't have to see a giant error stack on your console.
The feature is turned on by the
--no-panic
option or by the environment variable NODE_HTTP_SERVER_NO_PANIC.The output is something like:
Relevant issues
Refers partly to #665
What needs to be done:
Contributor checklist
--help
outputmaster
branchMaintainer checklist