Use startServer function
This commit is contained in:
parent
22c5c550be
commit
17f6a6bbe9
28
server.js
28
server.js
|
@ -4,11 +4,7 @@ const createApp = require('./server/createApp')
|
|||
|
||||
const port = parseInt(process.env.PORT, 10) || 5000
|
||||
|
||||
throng({
|
||||
workers: process.env.WEB_CONCURRENCY || 1,
|
||||
lifetime: Infinity,
|
||||
grace: 25000,
|
||||
start: function (id) {
|
||||
function startServer(id) {
|
||||
const server = http.createServer(createApp())
|
||||
|
||||
// Heroku dynos automatically timeout after 30s. Set our
|
||||
|
@ -18,18 +14,24 @@ throng({
|
|||
const message = `Timeout of 25 seconds exceeded`
|
||||
|
||||
socket.end([
|
||||
`HTTP/1.1 503 Service Unavailable`,
|
||||
`Date: ${(new Date).toGMTString()}`,
|
||||
`Content-Type: text/plain`,
|
||||
`Content-Length: ${Buffer.byteLength(message)}`,
|
||||
`Connection: close`,
|
||||
``,
|
||||
'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`))
|
||||
].join('\r\n'))
|
||||
})
|
||||
|
||||
server.listen(port, function () {
|
||||
console.log('Server #%s listening on port %s, Ctrl+C to stop', id, port)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
throng({
|
||||
workers: process.env.WEB_CONCURRENCY || 1,
|
||||
lifetime: Infinity,
|
||||
grace: 25000,
|
||||
start: startServer
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue