Skip to content

armgit / dashy

Public Imported from GitHub
0

🚀 A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:adhesive_bandage: Ensure stat finished before startSSLServer()

Marcell Fülöp91d4fd55c0f2
diff --git a/services/ssl-server.js b/services/ssl-server.js
index 13695bd6..c63b7db3 100644
--- a/services/ssl-server.js
+++ b/services/ssl-server.js
@@ -24,21 +24,23 @@ const printSuccess = () => {
// Check if the SSL certs are present and SSL should be enabled
let enableSSL = false;
-stat(httpsCerts.public).then(() => {
- stat(httpsCerts.private).then(() => {
+const checkCertificateFiles = stat(httpsCerts.public).then(() => {
+ return stat(httpsCerts.private).then(() => {
enableSSL = true;
}).catch(() => { printNotSoGood('Private key not present'); });
}).catch(() => { printNotSoGood('Public key not present'); });
const startSSLServer = (app) => {
- // If SSL should be enabled, create a secured server and start it
- if (enableSSL) {
- const httpsServer = https.createServer({
- key: fs.readFileSync(httpsCerts.private),
- cert: fs.readFileSync(httpsCerts.public),
- }, app);
- httpsServer.listen(SSLPort, () => { printSuccess(); });
- }
+ checkCertificateFiles.then(() => {
+ // If SSL should be enabled, create a secured server and start it
+ if (enableSSL) {
+ const httpsServer = https.createServer({
+ key: fs.readFileSync(httpsCerts.private),
+ cert: fs.readFileSync(httpsCerts.public),
+ }, app);
+ httpsServer.listen(SSLPort, () => { printSuccess(); });
+ }
+ });
};
const middleware = (req, res, next) => {