                         console.log err.message
                         callback err
                     else
-                        @client.startApp app.getHaibuDescriptor(), token, (err, result) =>
-                            if err
+                        @client.startApp app.getHaibuDescriptor(), token, (err, res, body) =>
+                            if err or res.statusCode isnt 200
                                 console.log "Error spawning app: #{app.name}"
-                                console.log err.message
-                                console.log err.stack
-                                callback(err)
+                                if err
+                                    console.log err.message
+                                    console.log err.stack
+                                    callback(err)
+                                else
+                                    console.log res.body
+                                    callback(res.body)
                             else
                                 console.info "Successfully update app: #{app.name}"
-                                callback null, result.body
+                                callback null, res.body
 
 
     # Send a uninstall request to haibu server ("clean" request).
     uninstallApp: (app, token, callback) ->
 
         console.info "Request haibu for cleaning #{app.name}..."
-        @client.uninstallApp app.getHaibuDescriptor(), token, (err, result) =>
-            if err
+        @client.uninstallApp app.getHaibuDescriptor(), token, (err, res, body) =>
+            if err or res.statusCode isnt 200
                 console.log "Error cleaning app: #{app.name}"
-                console.log err.message
-                console.log err.stack
-                callback(err)
+                if err
+                    console.log err.message
+                    console.log err.stack
+                    callback(err)
+                else
+                    console.log res.body
+                    callback(res.body)
             else
                 console.info "Successfully cleaning app: #{app.name}"
                 callback null

haibu = require('haibu-api')
HttpClient = require("request-json").JsonClient
MemoryManager = require("./memory").MemoryManager
haibuUrl = "http://localhost:9002/"
controllerClient = new HttpClient haibuUrl

                console.log err.message
                callback err
            else
                @client.startApp app.getHaibuDescriptor(), token, (err, res, body) =>
                    if err or res.statusCode isnt 200
                        console.log "Error starting app: #{app.name}"
                        if err
                            console.log err.message
                            console.log err.stack
                            callback(err)
                        else
                            console.log res.body
                            callback(res.body)
                    else
                        console.info "Successfully starting app: #{app.name}"
                        callback null, res.body

    # Send a stop request to haibu server
    stop: (app, token, callback) ->

        @client.stopApp app.slug, token, (err,res, body) =>
            if err or res.statusCode isnt 200
                console.log "Error stopping app: #{app.name}"
                if err
                    console.log err.message
                    console.log err.stack
                    callback(err)
                else
                    console.log res.body
                    callback(res.body)
            else
                console.info "Successfully stoppingg app: #{app.name}"
                callback null
