0

让 AWS S3 为我的 heroku 应用程序提供静态资产的问题几乎就在那里

一切都在本地工作,我运行我的 rake 任务,然后将资产预编译到 AWS(尽管终端中从来没有任何输出?)

然后到heroku,我在这里设置我的ENV变量

heroku config:add  aws_access_key=mysecretkey aws_secret_key=mypublickey aws_bucket=mybucketname

我有两个桶,一个用于开发,一个用于生产。我是否需要在 heroku:config 中设置任何其他内容?

这是我到目前为止所拥有的

配置文件

AssetSync.configure do |con|
con.fog_provider = 'AWS'
con.fog_region = 'eu-west-1'
con.fog_directory = ENV['aws_bucket']
con.aws_access_key_id = ENV['aws_access_key']
con.aws_secret_access_key = ENV['aws_secret_key']
con.prefix = "assets"
con.public_path = Pathname("./public")
end

这里的问题是,heroku 将读取和使用多少,我知道我必须在 heroku 中明确设置 ENV,但它会读取其余部分并执行其余任务,即它会读取前缀、public_path 等吗?

耙文件

require 'bundler/setup'
Bundler.require(:default)
require 'active_support/core_ext'
require './config/env' if File.exists?('config/env.rb')
require './config/config'

namespace :assets do
desc "Precompile assets"
task :precompile do
 AssetSync.sync
end

结尾

跑步时

heroku run rake assets:precompile

我得到输出

`rake assets:precompile` attached to terminal...up, run.2942 The source :rubygems is deprecated because HTTP requests are insecure. Please change your source to 'https://rubygems.org  (in /app)

然后它只是返回到终端,我期望在执行任务时列出所有要编译的资产的列表。在aws中检查我的存储桶后,它是空的

编辑

heroku 日志后的输出 --tail

 2013-03-19T10:55:50+00:00 heroku[api]: Starting process with command `bundle exec rake assets:precompile` by richlewis14@gmail.com
 2013-03-19T10:55:52+00:00 heroku[run.6701]: State changed from starting to up
 2013-03-19T10:55:53+00:00 heroku[run.6701]: Awaiting client
 2013-03-19T10:55:53+00:00 heroku[run.6701]: Starting process with command `bundle exec rake assets:precompile`
 2013-03-19T10:55:59+00:00 heroku[run.6701]: Client connection closed. Sending SIGHUP to all processes
 2013-03-19T10:56:00+00:00 heroku[run.6701]: Process exited with status 0
 2013-03-19T10:56:00+00:00 heroku[run.6701]: State changed from up to complete

大约 15 分钟后添加了更多

 !    Heroku client internal error.
 !    Search for help at: https://help.heroku.com
 !    Or report a bug at: https://github.com/heroku/heroku/issues/new

 Error:       An existing connection was forcibly closed by the remote host
(Errno::ECONNRESET)

  Command:     heroku logs --tail
  Version:     heroku-gem/2.35.0 (i386-mingw32) ruby/1.9.3
4

1 回答 1

1

This is a bundler error due to the source stated in the Gemfile. It is not related to the asset compilation per se.

Specify

source 'https://rubygems.org'

at the top of your Gemfile.

于 2013-03-19T09:32:27.337 回答