Capistrano由于资产而部署缓慢 - .sprockets-manifest *

时间:2016-02-15 11:11:08

标签: ruby-on-rails capistrano

在部署我们的API(根本不使用资产)时,它在此行上挂起约5分钟:

DEBUG [985661f8]    cannot access /var/www/api.staging/releases/20160208111413/public/assets/.sprockets-manifest*
DEBUG [985661f8]    : No such file or directory

我们已经在config / application.rb中禁用了资产:

config.assets.enabled = false

还有什么需要做的?我们正在使用这些版本:

  • capistrano(3.4.0)
  • capistrano-bundler(1.1.4)
  • capistrano-rails(1.1.3)
  • capistrano-rails-collection(0.0.3)

Capistrano日志:

INFO [42c93c96] Running /usr/local/rvm/bin/rvm 2.1.0@appyapi.staging do bundle exec rake assets:precompile as deploy@139.162.4.97
DEBUG [42c93c96] Command: cd /var/www/appyapi.staging/releases/20160223041856 && ( RAILS_ENV=staging /usr/local/rvm/bin/rvm 2.1.0@appyapi.staging do bundle exec rake assets:precompile )
INFO [42c93c96] Finished in 279.004 seconds with exit status 0 (successful).
DEBUG [f2410fde] Running /usr/bin/env if test ! -d /var/www/appyapi.staging/releases/20160223041856; then echo "Directory does not exist '/var/www/appyapi.staging/releases/20160223041856'" 1>&2; false; fi as deploy@139.162.4.97
DEBUG [f2410fde] Command: if test ! -d /var/www/appyapi.staging/releases/20160223041856; then echo "Directory does not exist '/var/www/appyapi.staging/releases/20160223041856'" 1>&2; false; fi
DEBUG [f2410fde] Finished in 0.081 seconds with exit status 0 (successful).
INFO [fd9b639a] Running /usr/bin/env mkdir -p /var/www/appyapi.staging/releases/20160223041856/assets_manifest_backup as deploy@139.162.4.97
DEBUG [fd9b639a] Command: cd /var/www/appyapi.staging/releases/20160223041856 && /usr/bin/env mkdir -p /var/www/appyapi.staging/releases/20160223041856/assets_manifest_backup
INFO [fd9b639a] Finished in 0.078 seconds with exit status 0 (successful).
DEBUG [462a5734] Running /usr/bin/env ls /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest* as deploy@139.162.4.97
DEBUG [462a5734] Command: cd /var/www/appyapi.staging/releases/20160223041856 && /usr/bin/env ls /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest*
DEBUG [462a5734]    ls: cannot access /var/www/appyapi.staging/releases/20160223041856/public/assets/.sprockets-manifest*
DEBUG [462a5734]    : No such file or directory
DEBUG [462a5734] Finished in 0.079 seconds with exit status 2 (failed).

1 个答案:

答案 0 :(得分:0)

好的,首先重要的是要知道“没有这样的文件或目录”错误是良性的。 Capistrano执行某些命令作为测试,并根据结果采用不同的代码路径,这些测试中的一些导致失败是完全正常的。除非Capistrano引发异常,否则您可以放心地忽略这些“错误”。

其次,即使您没有使用资产管道,似乎正在运行rake assets:precompile,因此没有用它。如果你没有任何资产,我很惊讶这一步可能需要很长时间,但让我们把它留给另一个讨论。

快速解决方案是不包括capistrano-rails插件的资产管道步骤。正如README中所述,您可以通过仅包含所需的步骤来实现此目的。

所以:

# Put these in your Capfile
require "capistrano/bundler"
require "capistrano/rails/migrations"

# REMOVE these lines so that asset pipeline steps are excluded
# require "capistrano/rails"
# require "capistrano/rails/assets"