rails 4.1无法通过capistrano 3进行部署

时间:2014-04-30 14:04:00

标签: ruby-on-rails ruby capistrano ruby-on-rails-4.1 libyaml

使用capistrano部署我的rails应用程序时出现非常奇怪的错误。有时它会部署,有时则不会。 例如,我向css添加一些东西(只有一个字符串),例如.my_some_class{width:10px} 之后部署失败。在我添加之前 - 它部署好了。 我确定没有其他任何改变因为我做了实验提交只包含一个css字符串。 我的配置:

rails 4.1.0
ruby 2.1.1p76

gem 'capistrano-rails', group: :development
gem 'capistrano-rvm', group: :development
gem 'capistrano-bundler', group: :development

部署日志结束:

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: rake exit status: 137
rake stdout: Nothing written
rake stderr: SafeYAML Warning
  ----------------

  You appear to have an outdated version of libyaml (0.1.4) installed on your system.

  Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads.

  For more info, see:
  https://www.ruby-lang.org/en/news/2014/03/29/heap-overflow-in-yaml-uri-escape-parsing-cve-2014-2525/

  The easiest thing to do right now is probably to update Psych to the latest version and enable
  the 'bundled-libyaml' option, which will install a vendored libyaml with the vulnerability patched:

  gem install psych -- --enable-bundled-libyaml



I, [2014-04-30T09:42:41.121037 #12193]  INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/Thumbs-82e32ea0cc1ce375db2805ceadd707ef.db
I, [2014-04-30T09:42:41.123108 #12193]  INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/agency_no_logo-a8544e60b8a38abeb431c2eb5089f7c6.png
I, [2014-04-30T09:42:41.461121 #12193]  INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/swipebox/img/loader-a66dde050b0b2447862919f2c4c37eda.gif

bash: line 1: 12193 Killed                  ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )

4 个答案:

答案 0 :(得分:19)

如上所述,可能你没有足够的RAM。

我通过在我的Ubuntu 14.04服务器上添加SWAP文件解决了问题:

root下:

dd if=/dev/zero of=/swapfile bs=1024 count=512k
mkswap /swapfile
swapon /swapfile

将下一行添加到/etc/fstab

 /swapfile       none    swap    sw      0       0 

echo 0 > /proc/sys/vm/swappiness
sudo chown root:root /swapfile 
sudo chmod 0600 /swapfile

检查SWAP(可能需要重新加载):

swapon -s 

- How To Add Swap on Ubuntu 14.04 @ Digital Ocean Community

答案 1 :(得分:12)

如果有人有同样的错误 - 问题在于托管。服务器没有ram(512mb),并且每次都会杀死编译css / js的过程。比我们改变费率计划,它有1gb内存,都成功部署。因此,如果资产预编译失败 - 只需尝试向服务器添加一些资源。 附:我在这里找到的类似问题Capistrano deploy - assets precompile error

答案 2 :(得分:5)

尝试重新启动服务器。为我工作。

答案 3 :(得分:0)

  

您似乎有一个过时的libyaml版本

更新libyaml