1
votes

Deploying plumber enabled R application to Bluemix / Cloud Foundry

I am trying to deploy plumber enabled R application to Bluemix / Cloud Foundry using https://github.com/beibeiyang/cf-buildpack-r.git build pack

The application is trivial (app.R):

library(plumber)

api <- plumb("api.R")

PORT <- as.numeric( Sys.getenv('PORT') )
message (PORT)

api$run(port=PORT)

and in my Procfile I have

web: Rscript app.R

In the log files I see that the installation (including the dependencies) completes successfully and my message is printed.

The issue is that I cant access the deployed app. If I use

health-check-type: port

then the app fails the health check and is not accessible at all. If I use

health-check-type: process 

The app starts but trying to access its URL results in 502 bad gateway.

1
I don't know R so I can't help too much but the difference between the two health checks is that process will only look to make sure that your process is up and running, while port will look to make sure it's running and also listening on the assigned port. Since the port health check is failing, it's likely the app isn't listening correctly for incoming connections. Double check you're getting a value from the PORT env variable (it will amost always be 8080). Maybe also add some logging to your app so you can get a better understanding of what it's doing. Hope that helps! - Daniel Mikusa
Thank you Daniel. I understand that the failing port check is not a mere inconvenience but indicates a fundamental issue. Unfortunately logging shows a random looking port value as expected but no further information. - David Soroko

1 Answers

1
votes

Looks like by default, plumber binds to the wrong host, the following works:

api$run(host="0.0.0.0", port=PORT)