最佳轨道解决方案为每分钟运行一个邮件

编程入门 行业动态 更新时间:2024-10-26 14:29:45
本文介绍了最佳轨道解决方案为每分钟运行一个邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

谢谢。

解决方案

  • 您可以使用 backgroundrb 。然而,这将消耗从你的主Rails应用程序的内存,因为它会产生一个专用于 backgroundrb 的Ruby实例。
  • 还可以在主应用程序中定义一个 SystemController (或等效的),其中各种操作对应于您的应用程序应执行的各种家庭任务。您可以使用 wget 或 curl ,其优点是它与您的主应用程序共享资源。根据你的偏执态度,或者对于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.

    解决方案

  • 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.
  • 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.)
  • 更多推荐

    最佳轨道解决方案为每分钟运行一个邮件

    本文发布于:2023-06-07 15:31:13,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/568652.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:每分钟   轨道   解决方案   邮件

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!