我是Google cloud的新手,当我尝试将ruby api部署到google cloud时,我遇到了这个问题,下面是我所做的:
我已经将我的ruby api上传到github (它在本地主机上工作得很好),这里是>> https://github.com/guisantogui/it
我已经看过hello world google教程>> https://cloud.google.com/ruby/getting-started/hello-world了
它像预期的那样工作,但当我上传我自己的应用程序时,我收到了这条http 502 bad gateway消息,日志如下:
2017-10-30 23:48:53 default[20171030t213633] => Booting Puma
2017-10-30 23:48:53 default[20171030t213633] => Rails 5.1.4 application starting in production
2017-10-30 23:48:53 default[20171030t213633] => Run `rails server -h` for more startup options
2017-10-30 23:48:53 default[20171030t213633] Puma starting in single mode...
2017-10-30 23:48:53 default[20171030t213633] * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-10-30 23:48:53 default[20171030t213633] * Min threads: 5, max threads: 5
2017-10-30 23:48:53 default[20171030t213633] * Environment: production
2017-10-30 23:48:53 default[20171030t213633] * Listening on tcp://0.0.0.0:3000
2017-10-30 23:48:53 default[20171030t213633] Use Ctrl-C to stop
2017-10-30 23:58:01 default[20171030t213633] "GET /" 502
2017-10-30 23:58:02 default[20171030t213633] "GET /favicon.ico" 502
2017-10-30 23:58:06 default[20171030t213633] "GET /" 502
2017-10-30 23:58:06 default[20171030t213633] "GET /favicon.ico" 502
2017-11-01 10:54:50 default[20171030t213633] "GET /" 502
2017-11-01 10:54:50 default[20171030t213633] "GET /favicon.ico" 502
2017-11-01 10:55:02 default[20171030t213633] "GET /favicon.ico" 502
2017-11-01 10:55:02 default[20171030t213633] "GET /tatoo_artis/list" 502最后,我认为更重要的是app.yaml文件:
entrypoint: bundle exec rails server Puma -p 3000
env: flex
runtime: ruby提前感谢,我不知道问题出在哪里,也不知道如何解决它!
发布于 2017-11-08 04:53:48
Google Cloud示例https://cloud.google.com/ruby/getting-started/hello-world使用Sinatra,而不是Rails。如果在app.yaml文件中检查https://github.com/GoogleCloudPlatform/ruby-docs-samples/tree/master/appengine/hello_world,它只包含:
# [START app_yaml]
runtime: ruby
env: flex
entrypoint: bundle exec ruby app.rb
# [END app_yaml]而app.rb只是一个简单的sinatra应用程序。
# [START app]
require "sinatra"
get "/" do
"Hello world!"
end
# [END app]Rails的配置稍微复杂一点。首先,GCP App Engine似乎不支持彪马(如果我说错了,请纠正我),但是rackup,你需要设置一些环境变量,比如SECRET_KEY (使用bundle exec rails secret),所以你的app.yaml文件应该是:
# [START app_yaml]
runtime: ruby
env: flex
entrypoint: bundle exec rackup --port $PORT
env_variables:
SECRET_KEY_BASE: [SECRET_KEY]
# [END app_yaml]请记住,您还需要运行:
RAILS_ENV=production bundle exec rails assets:precompile在运行之前
gcloud app deploy来预编译你的资源。
您需要的是本指南中的内容:https://cloud.google.com/ruby/rails/appengine,跳过最初的步骤(因为您已经有了应用程序),直接转到:“将应用程序部署到app Engine灵活环境”。
资料来源:谷歌指南:https://cloud.google.com/ruby/rails/appengine
代码:https://github.com/GoogleCloudPlatform/ruby-docs-samples/tree/master/appengine/rails-hello_world
编辑:我看到你的日志中有一些GET请求,所以可能支持Puma。尝试只设置SECRET_KEY并在部署之前预编译您的资产。
https://stackoverflow.com/questions/47055164
复制相似问题