最佳轨道解决方案为每分钟运行一个邮件 [英] Best rails solution for a mailer that runs every minute

查看:245
本文介绍了最佳轨道解决方案为每分钟运行一个邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,每分钟检查一个数据库的任何电子邮件,当时应该发送出去。我在想这是一个耙子任务,将由一个cron工作每分钟运行。这将是一个更好的解决方案吗?



根据我已经阅读,这不是理想的,因为rake必须每分钟加载整个轨道环境,这变得昂贵





谢谢。

解决方案


  1. 您可以使用 backgroundrb 。然而,这将消耗从你的主Rails应用程序的内存,因为它会产生一个专用于 backgroundrb 的Ruby实例。

  2. 还可以在主应用程序中定义一个 SystemController (或等效的),其中各种操作对应于您的应用程序应执行的各种家庭任务。您可以使用 wget curl crontab >,其优点是它与您的主应用程序共享资源。根据你的偏执态度,或者对于DOS(或其他类型的攻击)如何暴露这样的控制器到可能的外部世界,你可以选择阻止访问这个控制器的URL从除了环回之外的地址理想情况下在您的反向代理中,或者从控制器本身。)


I have an application that checks a database every minute for any emails that are supposed to be sent out at that time. I was thinking about making this a rake task that would be run by a cron job every minute. Would there be a better solution to this?

From what I have read, this isn't ideal because rake has to load the entire rails environment every minute and this becomes expensive.

Thoughts?

Thanks.

解决方案

  1. You can use backgroundrb. This, however, will eat up memory away from your main Rails app as it will spawn one Ruby instance exclusive to backgroundrb.
  2. You can also define a SystemController (or equivalent) in your main application, with various actions corresponding to the various household tasks your application should perform. You can "prod" it from crontab using wget or curl, the advantage being that it shares resources with your main application. Depending on how paranoid or you are, or on how vulnerable to DOS (or other types of attacks) exposing such a controller to, possibly, the outside world, you may choose to block access to this controller's URL from addresses other than the loopback (ideally in your reverse proxy, alternatively from the controller itself.)

这篇关于最佳轨道解决方案为每分钟运行一个邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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