From 993472e2cac854a878d79fb9521acc07c0e5bf56 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sun, 3 Nov 2013 23:33:55 +0300 Subject: [PATCH] Added some delay before listening for connection to avoid handling requests before DB connections are established. --- acs.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/acs.coffee b/acs.coffee index a7f0a01..62f120b 100644 --- a/acs.coffee +++ b/acs.coffee @@ -278,7 +278,6 @@ nextTask = (currentRequest) -> listener = (httpRequest, httpResponse) -> if httpRequest.method != 'POST' - #console.log '>>> 405 Method Not Allowed' httpResponse.writeHead 405, {'Allow': 'POST'} httpResponse.end('405 Method Not Allowed') return @@ -450,6 +449,8 @@ else httpServer = http.createServer(listener) httpsServer = https.createServer(options, listener) - httpServer.listen(config.ACS_PORT, config.ACS_INTERFACE) - httpsServer.listen(config.ACS_HTTPS_PORT, config.ACS_HTTPS_INTERFACE) - #console.log "Server listening on port #{config.ACS_PORT}" + # wait until DB connections are established + setTimeout(() -> + httpServer.listen(config.ACS_PORT, config.ACS_INTERFACE) + httpsServer.listen(config.ACS_HTTPS_PORT, config.ACS_HTTPS_INTERFACE) + , 1000)