How to disable console output on Rails 3 development server?

送分小仙女□ 提交于 2019-12-12 06:26:35

问题


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.


回答1:


By this you mean you want to hide the output shown in the console run you run rails s (or script/server in rails 2)?

Are you on Linux or OSX?

If so, then just do the following

$ rails server 1> /dev/null

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.




回答2:


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



来源:https://stackoverflow.com/questions/6363982/how-to-disable-console-output-on-rails-3-development-server

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