{fork} = require 'child_process'
# KodingLogger = require 'koding-logger'
os = require 'os'
processes = new (require 'processes')
option '-c', '--configPath [CONFIG]', 'Which config file to use.'
option '-n', '--numberOfWorkers [WORKERS]', 'The number of workers to run.'
option '-s', '--silent', 'Set this flag to suppress stdout'
option '-D', '--debug', 'Start the node project with the debugger'

task 'run', ({numberOfWorkers, configPath, silent})->
  configPath ?= '../../config/dev'
  {logger, configNumberOfWorkers} = require configPath
  numberOfWorkers ?= configNumberOfWorkers ? 1

  for _, i in Array +numberOfWorkers
    processes.fork
      name  : "authWorker-#{i}"
      cmd   : "./index -c #{configPath}"
      restart : yes
      restartInterval : 1000

  return