繁体   English   中英

Rails Elastic Beanstalk部署-sqlite3

[英]Rails Elastic Beanstalk deploy - sqlite3

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

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.

不知道为什么我会遇到这个Carrierwave错误。 我有那个文件可以和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

environment.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的工作方式。 我对弹性豆茎也这么认为

我遇到过同样的问题。 我发现了两个问题:

  1. 环境中缺少AWS环境变量(CarrierWave要求)(防止rake assets:precompile在创建过程中进行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]` 

尽管您将PostgreSQL用作AWS RDS中的数据库,并且已在Gemfiledatabase.yml指定了它,但EB仍然需要sqlite3。 也许是为自己使用。 因此,只需将sqlite3添加到Gemfile的生产模块中即可。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM