문제

I read the cloudfoundry documents on how to push/start application:

But neither of them tells when the cf push command or cf start command exits.

Starting app locally

For example, I have a nodejs application which can be started by command npm start which will keep blocking when running on local machine like:

$ npm start
> my-app@0.0.1 start /example-deployment-cf
> node index.js

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0

I never know when the nodejs listens to tcp port except I print out something in my application by kind of event handler for "start" event.

pushing app to cloudfoundry

$ cf push
...
1 of 1 instances running

App started

Showing health and status for app shawnzhu-test-node in org me@example.com / space dev as me@example.com...
OK

requested state: started
instances: 1/1
usage: 512M x 1 instances
urls: shawnzhu-test-node.pivotal.io

     state     since                    cpu    memory          disk   
#0   running   2014-05-12 02:32:05 PM   0.0%   56.1M of 512M   26.4M of 1G

it just simply (and magically) tells "App started" but didn't tell when (and why).

In real world, there will be lots of function calls in npm start like page generation and the app may not ready after cf push command exits. So I still need to use event handlers in code to print out log entries like "finished generating pages".

So my simple question is, what is the actual meaning of "app started" in cloudfoundry (before reading its code).

도움이 되었습니까?

해결책

If a route is assigned to the pushed app (like shawnzhu-test-node.pivotal.io in your case), then Cloud Foundry will check that the URL returns a 200 and report that it is running as soon as it does.

You can also do "cf logs shawnzhu-test-node" to see more detailed output from the app startup process.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top