简体   繁体   English

Rails控制台无法加载

[英]rails console doesn't load

Today, for no reason, my rails(2.1.0) application is very slow or even not responding. 今天,无缘无故,我的rails(2.1.0)应用程序非常慢,甚至没有响应。 It happens intermittently. 它间歇地发生。 So sometimes it works but again it doesn't work. 因此,有时它可以工作,但又一次不起作用。

When it doesn't work, I can't even load 'script/console production'. 当它不起作用时,我什至无法加载“脚本/控制台制作”。 I want to know where it's stuck. 我想知道它卡在哪里。 How do I load console step-by-step so that I can know which part causes the problem? 如何逐步加载控制台,以便我知道是哪个部分导致了问题?

Thanks. 谢谢。

Sam 山姆

If you are able, try temporarily removing all plugins/gems and see if the app will boot. 如果可以,请尝试暂时删除所有插件/宝石,然后查看应用程序是否可以启动。 One of those is likely the problem. 其中之一可能是问题所在。

The script/console file contains this. script/console文件包含此文件。

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'

You can find the commands/console file here for Rails 2.1. 您可以在此处找到Rails 2.1的命令/控制台文件

I recommend loading up irb and trying to load your app from there. 我建议加载irb并尝试从那里加载您的应用程序。

require 'config/boot'

If that works, then try stepping through the rest of the mentioned commands/console script to find out which part is the problem. 如果可行,请尝试逐步完成上述提到的其他命令/控制台脚本,以找出问题所在。

If the boot file won't load, take a look at that config/boot.rb file to see if you can determine which part isn't working. 如果引导文件无法加载,请查看该config/boot.rb文件,以查看是否可以确定哪个部分不起作用。 Good luck! 祝好运!

You could be running out of memory on your server and so the machine can't respond to you. 您的服务器上的内存可能已用完,因此计算机无法响应您。 If you are running mongrel then get monit onto it to limit the memory it can use and restart where necessary. 如果您正在运行杂种,请监视它以限制它可以使用的内存,并在必要时重新启动。

If you are using Passenger, try limiting the amount of instances, and if you have already done that look up a script that kills passenger instances when too big via a cron job. 如果您使用的是Passenger,请尝试限制实例的数量,如果已经这样做,则查找一个脚本,该脚本在通过cron作业太大时会杀死乘客的实例。

If it's not a memory issue then I'd probably need more information. 如果不是内存问题,那么我可能需要更多信息。

When all else fails, you should be able to use strace to debug what the script/application is actually doing. 当所有其他方法都失败时,您应该能够使用strace调试脚本/应用程序实际在做什么。 Note that this should only be one of the last resorts as it produces extremely verbose information (and also mostly limited to I/O actions). 请注意,这只能是最后的手段之一,因为它会产生极其冗长的信息(并且也仅限于I / O操作)。

Try using 'strace script/console production' for example 例如,尝试使用“ strace脚本/控制台生产”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM