 
     process.on 'uncaughtException', (err) =>
       if @_handler_callback
-        console.log "Worker #{worker_id.split('-')[0]} of task #{@name} will block current processing group" 
+        console.log "Worker [#{worker_id.split('-')[0]}] registered for Task [#{@name}] will block its current processing group" 
         @_handler_callback {do: 'block', message: err.stack}, null
       else
         @_try_exit()

  client.auth options.password if options.password?
  new Fairy client

# ### Exception & Interruption Handling
#
# Use `uncaughtException` and `SIGINT` to provide elegant exception and user
# interruption handling.

registered_workers = []

# Log active workers while waiting for all workers to clean-up.
log_registered_workers = ->
  console.log "\nFairy is waiting for #{registered_workers.length} workers to clean-up before exit:"
  for registered_worker in registered_workers
    worker_info = registered_worker.split '|'
    console.log "  * Client Id: [#{worker_info[0]}], Task: [#{worker_info[1]}]"

cleanup_required = off

# Fairy will enter cleanup mode before exit when:
#
#   + Received `SIGINT`, `SIGHUP`, or `SIGUSR2`.
#   + `uncaughtException` captured.
#
# If there's no registered workers, exit directly.
enter_cleanup_mode = ->
  if registered_workers.length
    log_registered_workers()
    cleanup_required = on
    exiting = on
  else
    return process.exit()

# When `SIGINT` (e.g. `Control-C`), `SIGHUP` or `SIGUSR2` is received,
# gracefully exit by notifying all workers entering cleanup mode and exit after
# all cleaned up.
process.on 'SIGINT', enter_cleanup_mode
process.on 'SIGHUP', enter_cleanup_mode
process.on 'SIGUSR2', enter_cleanup_mode

# When `uncaughtException` captured, **Fairy** can not tell if this is caught by
# the handling function, as well as which queue cause the exception. **Fairy**
# will fail all processing tasks and block the according group.
process.on 'uncaughtException', (err) ->
  console.log 'Uncaught Exception:', err.stack
  console.log 'Workers will block their processing groups before exit.' if registered_workers.length
  enter_cleanup_mode()

# Say goodbye on exit.
process.on 'exit', ->
  console.log "Fairy cleaned up, exiting..." if cleanup_required

# ## Helper Methods

# ### Get Public IP
#
