               multi.exec (multi_err, multi_res) =>
                 if multi_err
                   client.quit()
-                  return callback multi_err 
+                  return callback multi_err
                 if multi_res
                   client.quit()
+                  @redis.publish(@key('ENQUEUED'), "")
                   @statistics callback
                 else
                   reschedule callback


# 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:
#

#   + `uncaughtException` captured.
#
# If there's no registered workers, exit directly.
first_time = on
clean_up = ->
  log_registered_workers() unless first_time
  first_time = off
  return process.exit() unless workers.length
  # console.log 'abc'
  exiting = on
  for worker in workers
    worker.unregist() if worker.is_idling

# When below signals are captured, gracefully exit the program by notifying all
# workers entering cleanup mode and exit after all are cleaned up.
#
# + `SIGINT` (`Control-C`)
# + `SIGHUP`
# + `SIGQUIT`
# + `SIGUSR1`
# + `SIGUSR2`
# + `SIGTERM`
# + `SIGABRT`
capturable_signals = [
  'SIGINT'
  'SIGHUP'
  'SIGQUIT'
  'SIGUSR1'
  'SIGUSR2'
  'SIGTERM'
  'SIGABRT'
]

process.on signal, clean_up for signal in capturable_signals

# When `uncaughtException` is 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.
#
# TODO: Use `Domain` to manage exception handling.
process.on 'uncaughtException', (err) ->
  console.log 'Exception:', err.stack
  console.log 'Fairy workers will block their processing groups before exit.' if registered_workers.length
  clean_up()

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


# ## Helper Methods
