问题
I want to server R model using App Engine. I am following this example R with app engine, but stuck. I tried several methods but still have issues. Any guidance on this issue?
Please refer to my code app.yaml
runtime: custom
env: flex
Dockerfile
FROM gcr.io/gcer-public/plumber-appengine
LABEL maintainer="mark"
RUN R -e "install.packages(c('plumber'), repos='http://cran.rstudio.com/')"
WORKDIR /payload/
COPY [".", "./"]
EXPOSE 8080
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8080)"]
CMD ["schedule.R"]
schedule.R
#* @get /demoR
get_predict_length <- function(){
dataset <- iris
# create the model
model <- lm(Petal.Length ~ Petal.Width, data = dataset)
petal_width = "0.4"
#petal_width = '0.4'
# convert the input to a number
petal_width <- as.numeric(petal_width)
#create the prediction data frame
prediction_data <- data.frame(Petal.Width=petal_width)
# create the prediction
predict(model,prediction_data)
}
I deploy using 'gcloud app deploy and its successful. I get a link 'https://iris-custom-dot-my-project-name.appspot.com/'.
Final output in logs
Stackdriver logs show:
Starting server to listen on port 8080
when I click on app engine version https://iris-custom-dot-my-project-name.appspot.com/' , I get below message:
This site can’t be reached
回答1:
Office network issue
In my case the real issue was, my office network blocked port 8080, so when I connected from home or in office over mobile hotspot, it worked.
In general follow below steps to resolve the issue.
1) search google 'my public IP address"
2) Add your IP in firewall rules will resolve the issue.
either use gcloud commands
https://cloud.google.com/sdk/gcloud/reference/app/firewall-rules/create or
using GCP UI ( you can use any priority number which has not been used already)
来源:https://stackoverflow.com/questions/57735491/google-app-engine-flexible-with-docker-site-cannot-be-reached