Reputation: 4306
I have an application where I want to automatically deactivate a user 72 hours after they have been activated. I have set this up with Delayed Job, but am now wondering if that is the best option.
My question is, if I set a task for 72 hours in the future, will a worker be active for that entire 72 hours? (I'm concerned about this as Heroku charges by the hour)
I'm open to suggestion here as far as better ways of doing this goes. One idea I had was to set this up using an exp_date
column and check against that at sign in there by eliminating the need for DJ completely.
Upvotes: 0
Views: 252
Reputation: 8124
My question is, if I set a task for 72 hours in the future, will a worker be active for that entire 72 hours? (I'm concerned about this as Heroku charges by the hour)
Yes, it will be up all time. Delayed job continuously pings the database to see if there any job in its queue.
And, regarding the best option i think i rather put one column knows as valid_upto
and put the date till will be active. I only signins (or whatever) to only those user which has created_at
dates less then or equal to valid_upto
date. And, periodically may be once in month i will run one cron job to remove invalid
users.
And, like @leesungchul suggested, you can use that, that looks cool.
Upvotes: 1
Reputation: 111
You can use the workless gem which is an addon for delayed jobs so you don't leave your worker running constantly on heroku.
https://github.com/lostboy/workless
Upvotes: 0