     console.error "Could not close connections in time, forcefully shutting down"
     process.exit 1
   , 30*1000
-
-if process.env.NODETIME_KEY
-  require('nodetime').profile
-    accountKey: process.env.NODETIME_KEY
-    appName: process.env.CU_NODETIME_APP

eco = require 'eco'
checkIdent = require 'ident-express'
request = require 'request'

{User} = require 'model/user'
{Dataset} = require 'model/dataset'

# Doesn't seem to do much.
mongoose.connection.on 'error', (err) ->
  console.warn "MONGOOSE CONNECTION ERROR #{err}"

if process.env.NODETIME_KEY
  nodetime.profile
    accountKey: process.env.NODETIME_KEY
    appName: process.env.CU_NODETIME_APP

# TODO: move into npm module
nodetimeLog = (req, res, next) ->
  matched = _.find app.routes[req.method.toLowerCase()], (route) ->
    route.regexp.test req.url
  if matched.path isnt '*'
    res.nodetimePromise = nodetime.time 'Custard request ', matched.path, req.url
    oldSend = res.send
    res.send = (args... ) ->
      res.nodetimePromise.end()
      oldSend.apply res, args
  return next()

assets.jsCompilers.eco =
  match: /\.eco$/
