【问题标题】:Rails Elastic Beanstalk deploy - sqlite3Rails Elastic Beanstalk 部署 - sqlite3
【发布时间】:2016-09-24 22:11:44
【问题描述】:

我正在尝试将 Rails 应用程序部署到弹性 beanstalk,但出现错误。

INFO: Environment update is starting.                               
INFO: Deploying new version to instance(s).                         
ERROR: [Instance: i-053f6b1dfef0f156b] Command failed on instance. Return code: 1 Output: (TRUNCATED)...arrierwave.rb:2:in `block in <top (required)>'
/var/app/ondeck/config/initializers/carrierwave.rb:1:in `<top (required)>'
/var/app/ondeck/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace). 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-053f6b1dfef0f156b'. Aborting the operation.
ERROR: Failed to deploy application.                                

ERROR: Failed to deploy application.

不知道为什么我会收到此载波错误。我有那个文件可以与 S3 一起上传照片。

carrierwave.rb

CarrierWave.configure do |config|
    config.fog_credentials = {
        provider: "AWS",
        aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
        aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
    }
    config.fog_directory = ENV["AWS_S3_BUCKET"]
end

环境.rb

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Rails.application.initialize!

这是日志:

编辑 这里:

 ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
  /var/app/ondeck/config/initializers/carrierwave.rb:2:in `block in <top (required)>'
  /var/app/ondeck/config/initializers/carrierwave.rb:1:in `<top (required)>'
  /var/app/ondeck/config/environment.rb:5:in `<top (required)>'
  Tasks: TOP => environment

EDIT2 我的 gem 文件的一部分;

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

我用 postgresql 创建了 RDS。 database.yml 文件;

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: <%= ENV['RDS_DB_NAME'] %>#db/production.sqlite3
  username: <%= ENV['RDS_USERNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  port: <%= ENV['RDS_PORT'] %>

得到一个错误;

ERROR: [Instance: i-053f6b1dfef0f156b] Command failed on instance. Return code: 1 Output: (TRUNCATED)...sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.

我为什么要添加 gem sqlite3?,我已经在开发中,应该在生产中使用。这就是 Heroku 的工作原理。我对弹性豆茎也有同样的想法

【问题讨论】:

  • 查看日志:/var/log/eb-activity.log。它说什么?
  • 对不起,我怎么去那里?
  • 如消息所述:using console or EB CLI。或者,只是谷歌它。
  • 好的,看到问题并尝试解决。谢谢
  • 但问题是我已经在 application.yml 文件中声明了

标签: ruby-on-rails ruby amazon-web-services sqlite amazon-elastic-beanstalk


【解决方案1】:

我有同样的问题。我发现了两个问题:

  1. 环境中缺少 AWS 环境变量(CarrierWave 需要)(这会在创建过程中阻止 rake assets:precompile)。
  2. Gemfile 的生产中缺少 sqlite3(EB 需要)。

创建环境时需要配置AWS环境变量

eb create [app_name] -v --envvars AWS_ACCESS_KEY_ID=[access_key], AWS_ACCESS_KEY_SECRET=[key_secret]` 

事件虽然你在AWS RDS 中使用PostgreSQL 作为你的数据库,并且你已经在Gemfiledatabase.yml 中指定了它,但EB 仍然需要sqlite3。也许是为了自己的用途。所以只需将 sqlite3 添加到 Gemfile 的生产块。

【讨论】:

    【解决方案2】:

    从您的 database.yml 文件中 production: 的第一行中删除 &lt;&lt;: *default。 它会导致你混乱 b/c 在默认情况下你说 sqlite3 然后在接下来的 5 行中你提供 postgres 信息。

    【讨论】:

      猜你喜欢
      • 2016-03-04
      • 2019-11-22
      • 2015-09-18
      • 2012-11-13
      • 2013-08-31
      • 2016-09-18
      • 2015-09-20
      • 2019-02-13
      • 2019-05-25
      相关资源
      最近更新 更多