且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

每分钟运行一次的邮件程序的*** Rails 解决方案

更新时间:2022-12-26 15:47:12

  1. 您可以使用backgroundrb.但是,这会占用主 Rails 应用的内存,因为它会生成一个专用于 backgroundrb 的 Ruby 实例.
  2. 您还可以在主应用程序中定义一个 SystemController(或等效的),其中的各种操作对应于您的应用程序应执行的各种家务.您可以使用 wgetcurlcrontab 中生产"它,优点是它与您的主应用程序共享资源.根据您的偏执程度或您是否容易受到 DOS(或其他类型的攻击)将此类控制器暴露给外部世界的脆弱性,您可以选择阻止从环回以外的地址访问该控制器的 URL(理想情况下,在您的反向代理中,或者来自控制器本身.)
  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.)