   .timeout 1500
   .catch (e) ->
     console.log 'Service closing error: ', e
-    service?.redis.disconnect()
-    service?.io.engine.close()
+    service.redis.disconnect()
+    service.io.engine.close()
   .catchReturn()
 
 cleanup = (services, sockets, done) ->

    for socket in sockets
      socket?.disconnect()
    if customCleanup
      Promise.fromCallback (cb) ->
        customCleanup cb
    else
      Promise.map services, closeInstance
  .finally ->

  process.nextTick -> fn args...

parallel = (fns, cb) ->
  Promise.map(fns, Promise.fromCallback).asCallback(cb)

series = (fns, cb) ->
  Promise.mapSeries(fns, Promise.fromCallback).asCallback(cb)


module.exports = {
