cloudfoundry-samples / lattice-app

A Demo Application for Lattice
Apache License 2.0
6 stars 22 forks source link

Listen to ports in CF_INSTANCE_PORTS if it is present #8

Closed wendorf closed 8 years ago

wendorf commented 8 years ago

Diego may provide the CF_INSTANCE_PORTS environment variable, which is a JSON array of {"external": int, "internal": int} notifying the running process of the ports mapped to it. See https://github.com/cloudfoundry-incubator/receptor/blob/master/doc/environment.md for more details.

If this environment variable is present, we shoud prefer it over the "-ports" flag.

[#107248522]

cf-gitbot commented 8 years ago

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/108648192.

davidwadden commented 8 years ago

hey i just tried testing this with cf push .. i'm seeing the following (and not on master)

2015-12-11T16:09:07.73-0600 [CELL/0]     OUT Creating container
2015-12-11T16:09:08.06-0600 [CELL/0]     OUT Successfully created container
2015-12-11T16:09:08.40-0600 [APP/0]      OUT {"timestamp":"1449871748.408071518","source":"lattice-app","message":"lattice-app.lattice-app.starting","log_level":1,"data":{"ports":["8080","2222"]}}
2015-12-11T16:09:08.40-0600 [APP/0]      OUT {"timestamp":"1449871748.408347607","source":"lattice-app","message":"lattice-app.lattice-app.up","log_level":1,"data":{"port":"8080"}}
2015-12-11T16:09:08.41-0600 [APP/0]      OUT {"timestamp":"1449871748.408384085","source":"lattice-app","message":"lattice-app.lattice-app.up","log_level":1,"data":{"port":"2222"}}
2015-12-11T16:09:08.43-0600 [CELL/0]     OUT Exit status 1
2015-12-11T16:09:08.44-0600 [APP/0]      OUT Exit status 2
2015-12-11T16:09:08.45-0600 [API/0]      OUT App instance exited with guid a40cee58-ca32-498e-b4f3-33cfa562f76c payload: {"instance"=>"58789946-a88c-437e-4d92-3eb03085c533", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"2 error(s) occurred:\n\n* 2 error(s) occurred:\n\n* Exited with status 1\n* cancelled\n* cancelled", "crash_count"=>1, "crash_timestamp"=>1449871748451446330, "version"=>"47289b6e-0870-40a4-8071-80cdbd4fd19d"}

i think it's due to the fact that the CF_INSTANCE_PORTS env var is set as follows:

CF_INSTANCE_PORTS
[{"external":60028,"internal":8080},{"external":60029,"internal":2222}]
shalako commented 8 years ago

abandoning this as this environment variable isn't safe to honor. it contains ports that are used by the system and collisions occur.