ruby-on-rails – RSpec和Machinist错误:打开的文件太多

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – RSpec和Machinist错误:打开的文件太多前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
今天早上我遇到以下错误
  1. 14) Deal on creation sets frozen to false or nil
  2. Failure/Error: Unable to find matching line from backtrace
  3. Errno::EMFILE:
  4. Too many open files - identify -format %wx%h '/var/folders/BJ/BJcTANEBFxWcan28U2YEKE+++TI/-Tmp-/stream20120229-36866-4l1sa8.gif[0]'
  5. # ./spec/support/blueprints.rb:29:in `block in <top (required)>'

规格太慢了(即使用spork),所以它们没用.在模型中运行20个示例需要9分钟. blueprint.rb中的第29行位于以下块之间:

  1. Company.blueprint do
  2. name { "Office Tronic#{rand(10 ** 10)}" }
  3. website { 'officetronic.com' }
  4. subdomain {"officetronic#{rand(10 ** 10)}"}
  5. facebook { 'officetronic' }
  6. twitter { 'officetronic' }
  7. description { 'We are a company dealing with electronics and office supply' }
  8. address_line1 {'34 John Street'}
  9. address_line2 {''}
  10. post_code { 'EC2 3RR' }
  11. phone { '01 343243434' }
  12. city { 'London' }
  13. your_name { 'john Doe' }
  14. font_colour {'000000'}
  15. logo_file_name { 'mylogo.png' }
  16. logo_content_type { "application/png" }
  17. logo_file_size { 100 }
  18. end
  19.  
  20. Deal.blueprint do
  21. company {Company.make!}
  22. title { '50% off for web sites dev' }
  23. description { '50% of discount...' }
  24. quantity { 1 }
  25. min_quantity { 0 }
  26. start_time { Chronic.parse('one month') }
  27. end_time { Chronic.parse('two months') }
  28. price { 1500 } # in cents
  29. shipping_cost{ 100 } # in cents
  30. published { true }
  31. small_print { 'Some text' }
  32. show_map { true }
  33. post_code { 'E1 6BJ' }
  34. rrp {15}
  35. end

解决方法

打开的文件太多是操作系统错误,这意味着操作系统已用完文件句柄. Linux通常对可以同时打开多少文件有严格的限制,并且已达到该限制.

要临时增加限制,请先运行ulimit -n 8192,然后运行规范.

要永久性地增加限制,follow these instructions,并使用您用来运行规范的用户帐户的名称替换Nginx.

猜你在找的Ruby相关文章