簡體   English   中英

將 Rails 6 應用程序部署到 Google Cloud Platform App Engine 時出錯

[英]Error while deploying Rails 6 app to Google Cloud Platform App Engine

我已經使用 Rails 上的 Ruby 開發了應用程序的第一次迭代(ROR - v6.0.0;Ruby - v2.6.3)。 我需要將它部署到 gcp,谷歌雲平台,因為這是我工作的公司使用的。 我遵循了谷歌為此提供的教程,如此處所示 但是,無論我做什么,在推送快結束時我都會收到此錯誤:

8536b8dd72f7: Pushed
f66b9865f45c: Layer already exists
8f213bf0e9c7: Pushed
ce02b74896ad: Pushed
a79efcc05468: Pushed
latest: digest: sha256:93b405b42825c93798db12c14f4f5d5dd09c6fc3e32861a1a1f3947c338e45a2 size: 2419
DONE
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: production
* Listening on tcp://0.0.0.0:8080
bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.6.0/bin/rackup)
Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/pids/server.pid
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `initialize'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `open'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `write_pid'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:106:in `write_state'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/single.rb:103:in `run'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:186:in `run'
  /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/rack/handler/puma.rb:73:in `run'
  /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/server.rb:297:in `start'
  /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/lib/rack/server.rb:148:in `start'
  /app/vendor/bundle/ruby/2.6.0/gems/rack-2.0.7/bin/rackup:4:in `<top (required)>'
  /app/vendor/bundle/ruby/2.6.0/bin/rackup:23:in `load'
  /app/vendor/bundle/ruby/2.6.0/bin/rackup:23:in `<top (required)>'

奇怪的是,我嘗試使用全新的 rails 應用程序(相同的機器,相同的環境)按照谷歌的教程進行操作,但我得到了同樣的錯誤。 該帳戶已啟用計費,所以我認為不是這樣。 當我在本地運行該應用程序時,它工作得很好。 無論如何,這是我的“app.yml”文件:

entrypoint: bundle exec rackup --port $PORT
env: flex
runtime: ruby

env_variables:
    SECRET_KEY_BASE: [MY_SECRET_KEY_IS_HERE]

當我在本地機器上運行bundle exec rackup --port 8080時,應用程序啟動得很好。 我已經搜索了所有內容,但無法找到解決方案。 我看過類似的帖子,但要么沒有答案,要么沒有解決這個問題。 我正在考慮將應用程序“dockerizing”,但不確定是否可以解決任何問題; 但如果我理解正確,docker 是一種告訴其他機器如何運行特定指令集的方法,比如應用程序,這樣它幾乎可以在任何機器上運行。 Idk,這就是我能想到的。 歡迎任何和所有建議,我們將不勝感激。

感謝您花時間閱讀本文,否則我希望您度過愉快的一天。

我遇到過同樣的問題。

我正在使用puma gem 作為我的應用服務器。 我需要更改entrypoint文件中的入口app.yaml

entrypoint: bundle exec rails server Puma -p $PORT

可在此處找到文檔: https://cloud.google.com/appengine/docs/flexible/ruby/runtime

我遇到了同樣的問題。 我的/config/puma.rb有這個:

pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

這允許我使用env_variables將 pid 文件的位置設置為/tmp 我在app.yaml中添加了以下內容:

env_variables:
  PIDFILE: "/tmp/puma.pid"

一旦我這樣做了,錯誤就消失了。

我相信這是由於默認位置是只讀的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM