Skip to content

Commit

Permalink
Put the 'await' back with 'warmServer' for true production startup (g…
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMGreene authored Dec 7, 2020
1 parent 7a52639 commit f312814
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ if (!module.parent) {
// check that the development server is not already running
portUsed.check(port).then(async status => {
if (status === false) {
// If in production, warm the server at the start
if (process.env.NODE_ENV === 'production') warmServer()
// If in a deployed environment, warm the server at the start
if (process.env.NODE_ENV === 'production') {
// If in a true production environment, wait for the cache to be fully warmed.
if (process.env.HEROKU_PRODUCTION_APP) {
await warmServer()
} else {
// If not in a true production environment, don't wait for the cache to be fully warmed.
// This avoids deployment timeouts in environments with slower servers.
warmServer()
}
}

// workaround for https://github.com/expressjs/express/issues/1101
const server = require('http').createServer(app)
Expand Down

0 comments on commit f312814

Please sign in to comment.