 
 # Monitor the services as they spin-up.
 monitor = async (context, services) ->
-  console.log 1
   {cluster} = context
-  console.log 2
-  #while true
-  # Read the status of all services
-  status = yield get_status cluster, services
-  console.log 3, status
-  # Check for success. All services must be "active" to pass, but a single
-  # failure ruins the whole thing.
-  console.log 4
-  is_active = (x) -> x == "active"
-  is_failed = (x) -> x == "failed"
-  console.log 5
-  #success = collect map is_active, status
-  #failure = collect map is_failed, status
-  success = [true, true]
-  failure = [false, false]
-  console.log 6, success, failure
-  if true in failure
-    return false        # Failure detected. All is lost, haha.
-  else if false !in success
-    return true         # *All* services are online and ready.
-  else
-    yield sleep 10000   # Continue polling.
+  while true
+    # Read the status of all services
+    status = yield get_status cluster, services
+
+    # Check for success. All services must be "active" to pass, but a single
+    # failure ruins the whole thing.
+    is_active = (x) -> x == "active"
+    is_failed = (x) -> x == "failed"
+    success = collect map is_active, status
+    failure = collect map is_failed, status
+
+    if true in failure
+      return false        # Failure detected. All is lost, haha.
+    else if false !in success
+      return true         # *All* services are online and ready.
+    else
+      yield sleep 10000   # Continue polling.
 
 module.exports = {monitor}

# This file contains helper functions meant to access the main cluster, parse
# output from fleetctl and deliver status information to the Huxley API server.

{async, shell, sleep, collect, map} = require "fairmont"
api = require "./api"



  # Parse the output for structured data.
  data = stdout.split("\n")[1..]
  status = {}
  for line in data
    continue if line == ""

    fields = line.split "\t"
    name = fields[0][...-8]

    # Save service status, ignoring those not part of this deployment.
    if name in keys services
      status[name] = fields[2]
    else
      continue
