Rake assets:precompile gets killed when there is a console session open in production

家住魔仙堡 提交于 2019-12-03 06:53:32

问题


On my production server, which is hosted on digital ocean, if that helps, Ubuntu 12.04, I have RoR 4 and rake 10.1.1.

When I deploy, I run rake assets:precompile, and I've noticed a strange issue where if I have a rails console session open when I do this, I get the following output

~# rake assets:precompile
~# Killed

It's mainly annoying, but the reason I want it resolved is when hiring new developers, there will be deploy/console conflict nightmare.

Thanks,

Brian


回答1:


Your precompile process is probably being killed because you are running out of RAM. You can confirm this by running top in another ssh session. To fix this, create a swap file that will be used when RAM is full.

Create SWAP Space on Ubuntu You will probably end up needing some swap space if you plan on using Rails on Digital Ocean 512MB RAM droplet. Specifically, you will run out of RAM when compiling the assets resulting in the process being quietly killed and preventing successful deployments.

To see if you have a swap files:

sudo swapon -s

No swap file shown? Check how much disk space space you have:

 df

To create a swap file:

Step 1: Allocate a file for swap

sudo fallocate -l 2048m /mnt/swap_file.swap

Step 2: Change permission

sudo chmod 600 /mnt/swap_file.swap

Step 3: Format the file for swapping device

sudo mkswap /mnt/swap_file.swap

Step 4: Enable the swap

sudo swapon /mnt/swap_file.swap

Step 5: Make sure the swap is mounted when you Reboot. First, open fstab

sudo nano /etc/fstab

Finally, add entry in fstab (only if it wasn't automatically added)

# /etc/fstab
/mnt/swap_file.swap none swap sw 0 0 

Save and exit. You're done adding swap. Now your rake assets:precompile should complete without being killed.




回答2:


Rake assets:precompile is a memory eating process.

So make sure you have enough RAM before using that command




回答3:


I have an opsworks stack on aws and I'd to change my instance type. I was using t1.micro and i just changed it to t1.small

Thanks a lot.




回答4:


This uses a lot of RAM. To check how much available RAM memory you have free, use the command

free -m

This will show the available RAM in MB

A temporary solution would be to create a swap space.

I was going to add this as a comment to Jason R post above before you go into his steps, just to make sure it is a RAM resource issue.

you could also run

echo {1,2,3} > /proc/sys/vm/drop_caches

to clean up the cache memory, but it probably will not free up enough.




回答5:


This might help someone. For me, since i couldn't use 'fallocate' command, i had to do:

sudo dd if=/dev/zero of=/mnt/4GB.swap bs=4096 count=1048576
sudo chmod 600 /mnt/4GBB.swap
sudo mkswap /mnt/4GB.swap
sudo swapon /mnt/4GB.swap


来源:https://stackoverflow.com/questions/22272339/rake-assetsprecompile-gets-killed-when-there-is-a-console-session-open-in-produ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!