耙资产:生产中打开控制台会话时,预编译将被杀死 [英] Rake assets:precompile gets killed when there is a console session open in production

查看:89
本文介绍了耙资产:生产中打开控制台会话时,预编译将被杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在托管于数字海洋上的生产服务器上,如果有帮助,那么在Ubuntu 12.04上,我具有RoR 4和rake 10.1.1。

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.

部署时,我运行 rake asset:precompile ,我注意到一个奇怪的问题,如果我有一个 rails控制台会话打开时会得到以下输出

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.

谢谢

Brian

推荐答案

您的预编译进程可能已被杀死,因为您的RAM不足了。您可以通过在另一个ssh会话中运行 top 来确认。要解决此问题,请创建一个交换文件,该文件将在RAM已满时使用。

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.

在Ubuntu上创建SWAP空间
如果计划在Digital Ocean上使用512MB的Rails,则可能最终需要一些交换空间。 RAM小滴。特别是,在编译资产时,您将用完RAM,从而导致进程被悄悄终止并阻止成功部署。

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.

查看是否有交换文件:

sudo swapon -s

没有显示交换文件?检查您有多少磁盘空间:

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

 df

创建交换文件:

步骤1:分配文件进行交换

Step 1: Allocate a file for swap

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

步骤2:更改权限

sudo chmod 600 /mnt/swap_file.swap

第3步:格式化用于交换设备的文件

Step 3: Format the file for swapping device

sudo mkswap /mnt/swap_file.swap

第4步:启用交换

sudo swapon /mnt/swap_file.swap

步骤5:重新启动时,请确保已安装交换。首先,打开fstab

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

sudo nano /etc/fstab

最后,在fstab中添加条目(仅在未自动添加的情况下)

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

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

保存并退出。您已完成添加交换。现在,您的 rake资产:预编译应该可以完成而不会被杀死。

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

这篇关于耙资产:生产中打开控制台会话时,预编译将被杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆