Added error handling for HTTPS key/cert file loading.
This commit is contained in:
parent
069cb423fd
commit
401b9e4fee
|
|
@ -91,6 +91,7 @@ let webServer = null;
|
|||
|
||||
//If we're using HTTPS
|
||||
if(config.protocol.toLowerCase() == "https"){
|
||||
try{
|
||||
//Read key/cert files and store contents
|
||||
const httpsOptions = {
|
||||
key: fs.readFileSync(config.ssl.key),
|
||||
|
|
@ -98,6 +99,15 @@ if(config.protocol.toLowerCase() == "https"){
|
|||
};
|
||||
|
||||
webServer = https.createServer(httpsOptions, app);
|
||||
}catch(err){
|
||||
if(err.path != null && err.path != ""){
|
||||
console.log(`Error opening key/cert file: ${err.path}`);
|
||||
}else{
|
||||
console.log("Unknown error occured while starting HTTPS server! Bailing out!");
|
||||
console.log(err);
|
||||
}
|
||||
process.exit();
|
||||
}
|
||||
|
||||
//Otherwise
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Reference in a new issue