似乎不再发送您的问题?在这种情况下,我不会通过 cronjob 执行此操作。我会通过以下方式做到这一点:https ://github.com/bvandenbos/resque-scheduler
因此,每当安排一个问题时,您只需将其添加到延迟队列中,resque-scheduler 就会在时间到时将它们移动到正确的工作队列中。
这样您就不必担心某种轮询 cronjob,这将由 resque-scheduler 自动完成。您还可以免费获得通过 resque 发送短信的异步处理。因此,如果您必须发送大量短信,您可以并行运行它们。
所以它会是这样的:
- 保存问题后,您将在延迟队列中排队,以便将来发送问题
- when the date comes up, the message is moved onto 'ready to send'-queue, which is in charge of gathering all the users the question needs to be sent to.
- for each of those users you create another message on the 'ready to send'-queue
- the 'ready to send'-queue will then send out the actual SMSes
You then can run many workers on the 'ready to send'-queue and have the SMSes be sent out in parallel. You also get error handling for free with resque, it gahers all messages that resulted in an exception in a 'failure' queue, which you can then debug or reschedule again