asset_sync Gem使Heroku在预编译时挂起

时间:2012-11-14 18:40:35

标签: ruby-on-rails heroku amazon-web-services asset-pipeline precompile

我正在使用带有Heroku部署的asset_sync gem(Rails 3.2.3)。预编译在本地很好地工作(将资产推送到我的AWS桶而没有问题),但是当我推送到Heroku时,它会在资产预编译期间挂起。

Preparing app for Rails asset pipeline
Running: rake assets:precompile
AssetSync: using default configuration from built-in initializer

然后最终没有解释就超时了:

/app/slug-compiler/lib/utils.rb:66:in `block (2 levels) in spawn': command='/app/slug-compiler/lib/../../tmp/buildpacks/ruby/bin/compile /tmp/build_33de6far26atq /app/tmp/repo.git/.cache' exit_status=0 out='' at=timeout elapsed=900.1074194908142 (Utils::TimeoutError)
    from /app/slug-compiler/lib/utils.rb:52:in `loop'
    from /app/slug-compiler/lib/utils.rb:52:in `block in spawn'
    from /app/slug-compiler/lib/utils.rb:47:in `popen'
    from /app/slug-compiler/lib/utils.rb:47:in `spawn'
    from /app/slug-compiler/lib/buildpack.rb:38:in `block in compile'
    from /app/slug-compiler/lib/buildpack.rb:36:in `fork'
    from /app/slug-compiler/lib/buildpack.rb:36:in `compile'
    from /app/slug-compiler/lib/slug.rb:487:in `block in run_buildpack'
    from /app/slug-compiler/lib/utils.rb:121:in `log'
    from /app/slug-compiler/lib/slug.rb:743:in `log'
    from /app/slug-compiler/lib/slug.rb:486:in `run_buildpack'
    from /app/slug-compiler/lib/slug.rb:116:in `block (2 levels) in compile'
    from /app/slug-compiler/lib/utils.rb:102:in `block in timeout'
    from /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
    from /app/slug-compiler/lib/utils.rb:102:in `rescue in timeout'
    from /app/slug-compiler/lib/utils.rb:97:in `timeout'
    from /app/slug-compiler/lib/slug.rb:104:in `block in compile'
    from /app/slug-compiler/lib/utils.rb:121:in `log'
    from /app/slug-compiler/lib/slug.rb:743:in `log'
    from /app/slug-compiler/lib/slug.rb:103:in `compile'
    from /app/slug-compiler/bin/slugc:85:in `block in <main>'
    from /app/slug-compiler/lib/slug.rb:495:in `block in lock'
    from /app/slug-compiler/lib/repo_lock.rb:44:in `call'
    from /app/slug-compiler/lib/repo_lock.rb:44:in `run'
    from /app/slug-compiler/lib/slug.rb:495:in `lock'
    from /app/slug-compiler/bin/slugc:66:in `<main>'
 !     Heroku push rejected, failed to compile Ruby/rails app

$ heroku config表明我已经设置了以下我一次又一次检查过的ENV。我知道它们是正确的值,因为它们在我在本地预编译时起作用:

AWS_ACCESS_KEY_ID:          XXXX
AWS_SECRET_ACCESS_KEY:      XXXX
FOG_DIRECTORY:              XXXX
FOG_PROVIDER:               AWS
FOG_REGION:                 eu-west-1

我没有签入我的公共/资产文件夹,我在production.rb中进行了以下设置:

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed (This would involve live compilation and a big performance issue)
  config.assets.compile = false

  # Generate digests for assets URLs (Fingerprinting)
  config.assets.digest = true

  # (Heroku requires that this be false)
  config.assets.initialize_on_precompile = false

  # AWS Bucket
  config.action_controller.asset_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"

我已经在asset_sync的README中提到了Heroku上的以下内容:

$heroku labs:enable user-env-compile -a myapp

可能导致这些问题的原因和/或如何进一步调试它们。我无法看到一种方法来获取有关为什么预编译挂在Heroku上的更多信息。

1 个答案:

答案 0 :(得分:1)

原来这是Sass编译器中的一个问题。在没有任何错误的情况下,它窒息了一些东西。我设法使用概述here的步骤获得更多信息,等待它挂起,然后退出进程。这给了我一个回溯到sass解析器的堆栈跟踪。认为这是某种循环依赖。