mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-18 06:21:35 +03:00
🔀 Merge pull request #760 from marekful/FIX/start-ssl-on-slow-filesystem
🩹 Ensure stat finished before startSSLServer()
This commit is contained in:
commit
51f6e30026
@ -24,21 +24,23 @@ const printSuccess = () => {
|
|||||||
|
|
||||||
// Check if the SSL certs are present and SSL should be enabled
|
// Check if the SSL certs are present and SSL should be enabled
|
||||||
let enableSSL = false;
|
let enableSSL = false;
|
||||||
stat(httpsCerts.public).then(() => {
|
const checkCertificateFiles = stat(httpsCerts.public).then(() => {
|
||||||
stat(httpsCerts.private).then(() => {
|
return stat(httpsCerts.private).then(() => {
|
||||||
enableSSL = true;
|
enableSSL = true;
|
||||||
}).catch(() => { printNotSoGood('Private key not present'); });
|
}).catch(() => { printNotSoGood('Private key not present'); });
|
||||||
}).catch(() => { printNotSoGood('Public key not present'); });
|
}).catch(() => { printNotSoGood('Public key not present'); });
|
||||||
|
|
||||||
const startSSLServer = (app) => {
|
const startSSLServer = (app) => {
|
||||||
// If SSL should be enabled, create a secured server and start it
|
checkCertificateFiles.then(() => {
|
||||||
if (enableSSL) {
|
// If SSL should be enabled, create a secured server and start it
|
||||||
const httpsServer = https.createServer({
|
if (enableSSL) {
|
||||||
key: fs.readFileSync(httpsCerts.private),
|
const httpsServer = https.createServer({
|
||||||
cert: fs.readFileSync(httpsCerts.public),
|
key: fs.readFileSync(httpsCerts.private),
|
||||||
}, app);
|
cert: fs.readFileSync(httpsCerts.public),
|
||||||
httpsServer.listen(SSLPort, () => { printSuccess(); });
|
}, app);
|
||||||
}
|
httpsServer.listen(SSLPort, () => { printSuccess(); });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const middleware = (req, res, next) => {
|
const middleware = (req, res, next) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user