【发布时间】:2019-08-31 05:43:56
【问题描述】:
我想使用 App Engine 为 R 模型提供服务器。 我正在关注这个例子R with app engine,但卡住了。我尝试了几种方法,但仍然有问题。关于这个问题的任何指导?
请参考我的代码 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)
}
我使用'gcloud app deploy 进行部署并且成功了。我得到一个链接“https://iris-custom-dot-my-project-name.appspot.com/”。
日志中的最终输出
Stackdriver 日志显示:
Starting server to listen on port 8080
当我点击应用引擎版本 https://iris-custom-dot-my-project-name.appspot.com/' 时,我收到以下消息:
无法访问此网站
【问题讨论】:
标签: r docker google-app-engine app-engine-flexible plumber