如何禁用 Rails 3 开发服务器上的控制台输出?
如何禁用 Rails 3 应用程序上的控制台输出? 更具体地说,我想至少禁用 Mailer 输出,它输出整个电子邮件内容,包括图片,从而使操作处理速度慢得多(发送电子邮件几乎需要 10 秒)。
ps:我认为速度减慢是因为输出,如果它可以来自其他来源,例如慢速 smtp 服务器(它是 gmail atm,所以不是。)或其他类似的东西,请告诉我。
How can I disable the console output on a Rails 3 application?
More specifically, I want to disable at least the Mailer output, that outputs the entire email content, including the pictures, making the action processing much slower (it takes almost 10sec to send an email).
ps: I think the slowdown is because of the output, if it can be from another source, such as slow smtp server (it's gmail atm, so no.) or something else like that please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的意思是你想隐藏运行
rails s
(或rails 2中的script/server
)的控制台中显示的输出?您使用的是 Linux 还是 OSX?
如果是这样,那么只需执行以下操作
,即可将标准输出的所有输出发送到黑洞中。
那么现在您正尝试从您的开发机器发送电子邮件吗?
我试图避免这种情况,
因为事故即将发生
您将向客户发送测试数据。
尝试邮件捕捉器
http://mailcatcher.me/
它可以让您捕获您的应用程序将发送的所有电子邮件
在漂亮的网络界面中展示它们
重要的是,避免了意外向客户发送带有随机测试数据的真实电子邮件的风险。
By this you mean you want to hide the output shown in the console run you run
rails s
(orscript/server
in rails 2)?Are you on Linux or OSX?
If so, then just do the following
this sends all output from stdout into a blackhole.
So right now you are trying to send emails from your dev machine?
I try to avoid this,
as accidents are going to happen
and you'll send clients test data.
Try Mailcatcher
http://mailcatcher.me/
It lets you catch all the emails your app would be sending
shows them off in a nice web interface
and importantly avoids the risk of accidentally sending real emails to customers with random test data.
SMTP 服务器(甚至 Gmail)的响应确实需要一些时间。您宁愿使用邮件队列将所有电子邮件存储在数据库中,然后通过独立进程发送它们。
例如 https://github.com/beam/action-mailer-queue
关于记录器 -确保您的日志记录级别为 :error 或 :fatal。如果没有,请运行:
config.log_level = :error
SMTP server's (even Gmail) response can really take some time. You'd rather use a mail queue that stores all emails in a database and then they are sent by an independent process.
E.g. https://github.com/beam/action-mailer-queue
Concerning logger - make sure that your logging level is :error or :fatal. If not, run:
config.log_level = :error