我正在尝试将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.
不知道为什么我收到此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 我宝石文件的一部分;
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的工作方式。我认为弹性豆茎是一样的
答案 0 :(得分:0)
我有同样的问题。我发现了两个问题:
rake assets:precompile
)。创建环境时,您需要配置AWS环境变量:
eb create [app_name] -v --envvars AWS_ACCESS_KEY_ID=[access_key], AWS_ACCESS_KEY_SECRET=[key_secret]`
事件虽然您在AWS RDS中使用PostgreSQL作为数据库,并且您已在Gemfile
和database.yml
中指定了它,但EB仍然需要sqlite3。也许是为了自己的用法。所以只需将sqlite3添加到Gemfile的生产块中。
答案 1 :(得分:0)
从database.yml文件中<<: *default
的第一行删除production:
。
它会导致你混乱b / c默认你说sqlite3然后在接下来的5行你提供postgres信息。