 uuid = require 'node-uuid'
 Q = require 'q'
 logger = require 'winston'
-logger.level = config.logger.level
-logger.colorize = true
+logger.remove logger.transports.Console
 cluster = require 'cluster'
 numCPUs = require('os').cpus().length
 nconf = require 'nconf'



  exports.startRestartServerAgenda = (done) ->
    if cluster.isMaster
      # restart myself in 2s
      agenda = new Agenda db: { address: config.mongo.url }
      agenda.define 'Restart Server', {priority: 'high', concurrency: 1}, (job, done) -> restartServer done
      agenda.start()
      agenda.schedule "in 2 seconds", 'Restart Server'
      done()
    else
      # notify master to restart all workers in 2s
      setTimeout ->
        logger.debug 'Sending restart cluster message...'
        process.send('restart-all')
      , 2000

  cluster.on 'listening', (worker, address) ->
    logger.debug "worker #{worker.process.pid} is now connected to #{address.address}:#{address.port}"
else
  # configure worker logger
  logger.add logger.transports.Console,
    colorize: true
    label: "worker#{cluster.worker.id}"
    level: config.logger.level

  # Configure mongose to connect to mongo
  mongoose.connect config.mongo.url

