Best rails solution for a mailer that runs every minute

前端 未结 4 904
有刺的猬
有刺的猬 2021-01-01 01:00

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 wou

4条回答
  •  时光说笑
    2021-01-01 01:14

    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.)

提交回复
热议问题