Timeout after 25s
This commit is contained in:
parent
30cd271339
commit
995780bcbb
|
@ -71,21 +71,21 @@ function createServer(publicDir, statsFile) {
|
|||
// Heroku dynos automatically timeout after 30s. Set our
|
||||
// own timeout here to force sockets to close before that.
|
||||
// https://devcenter.heroku.com/articles/request-timeout
|
||||
// server.setTimeout(25000, socket => {
|
||||
// const message = `Timeout of 25 seconds exceeded`;
|
||||
server.setTimeout(25000, socket => {
|
||||
const message = `Timeout of 25 seconds exceeded`;
|
||||
|
||||
// socket.end(
|
||||
// [
|
||||
// "HTTP/1.1 503 Service Unavailable",
|
||||
// "Date: " + new Date().toGMTString(),
|
||||
// "Content-Length: " + Buffer.byteLength(message),
|
||||
// "Content-Type: text/plain",
|
||||
// "Connection: close",
|
||||
// "",
|
||||
// message
|
||||
// ].join("\r\n")
|
||||
// );
|
||||
// });
|
||||
socket.end(
|
||||
[
|
||||
"HTTP/1.1 503 Service Unavailable",
|
||||
"Date: " + new Date().toGMTString(),
|
||||
"Content-Length: " + Buffer.byteLength(message),
|
||||
"Content-Type: text/plain",
|
||||
"Connection: close",
|
||||
"",
|
||||
message
|
||||
].join("\r\n")
|
||||
);
|
||||
});
|
||||
|
||||
return server;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,10 @@ throng({
|
|||
start: startServer,
|
||||
lifetime: Infinity,
|
||||
|
||||
// Heroku shuts down processes forcefully after 30 seconds,
|
||||
// so make sure we exit before that happens.
|
||||
// In production, increase throng's default grace period to allow
|
||||
// servers that are still handling requests to finish. Heroku shuts
|
||||
// down processes forcefully after 30 seconds, so exit before that
|
||||
// happens to avoid an exit timeout.
|
||||
// https://devcenter.heroku.com/articles/dynos#shutdown
|
||||
grace: 25000
|
||||
grace: process.env.NODE_ENV === "production" ? 25000 : 5000
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue