2

我将asset_sync gem 与Heroku 部署(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,我一次又一次地检查了这些 ENV。我知道它们是正确的值,因为它们在我本地预编译时起作用:

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

我没有签入我的 public/assets 文件夹,并且我的 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的自述文件中所述,我在Heroku上设置了以下内容:

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

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

4

1 回答 1

1

Turns out it was a problem in the Sass compiler. It was choking on something without throwing any kind of error. I managed to get a bit more information using the steps outlined here, by waiting until it was hung, then quitting the process. That gave me a stack trace back to the sass parser. Think it was some kind of circular dependency.

于 2012-11-15T18:24:53.630 回答