i need your help!
I have deployed my Rails app in Ubuntu 12.04, using Nginx, MySQL, Solr and Unicorn.
Every mentioned service is started, instead of unicorn, which says following:
I, [2013-02-11T16:10:20.187989 #27547] INFO -- : Refreshing Gem list I, [2013-02-11T16:10:52.159198 #27547] INFO -- : unlinking existing socket=/var/www/staging/shared/unicorn.sock I, [2013-02-11T16:10:52.159488 #27547] INFO -- : listening on addr=/var/www/staging/shared/unicorn.sock fd=12 E, [2013-02-11T16:10:52.161513 #27547] ERROR -- : Cannot allocate memory - fork(2) (Errno::ENOMEM) /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:496:in
fork' /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:496:in
spawn_missing_workers' /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:142:instart' /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/bin/unicorn_rails:209:in
' /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:inload' /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:in
'
VDS has 1.5Gb of RAM and it's enough for unicorn:
cat /proc/meminfo
MemTotal: 1585152 kB MemFree: 989580 kB Cached: 425296 kB Active: 348504 kB Inactive: 175356 kB Active(anon): 98488 kB Inactive(anon): 76 kB Active(file): 250016 kB Inactive(file): 175280 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 204800 kB SwapFree: 204800 kB Dirty: 12 kB Writeback: 0 kB AnonPages: 98564 kB Shmem: 3604 kB Slab: 71680 kB SReclaimable: 66144 kB SUnreclaim: 5536 kB
I have unicorn_rails v4.5.0
Unicorn starts by following command:
bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D
What i'm doing wrong here?
Hmm, i remembered, that previously i had following strange error:
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327' -c 'cd /var/www/staging/current && bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D'"
Maybe it is somehow related to memory problems…
It seems the error is happening when forking new processes. You may need to reduce the workers in your config/unicorn.rb file. Each worker is a process and each process loads the application environment into the RAM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With