Reputation: 14872
I'm currently doing
http://localhost:3000/MyApp/update
which does everything I want it to do. I tried delayed_job but it didn't work, so I'm trying to use cron or some other method to do the same thing - I need to access update in order for that task to be done, and I'd like it to be done in the background, multiple times.
I also considered cron + wget but it seems rather hacky, and Mac doesn't come with wget by default (which is minimal, but cause for looking at alternatives).
What's the best approach to do so?
Thanks!
Upvotes: 0
Views: 152
Reputation: 32748
You can execute arbitrary Ruby code in the context of a Rails environment by using runner
, e.g. say you had a file like:
User.all.each { |u| u.send_email_update }
than you could run it from the command line like:
RAILS_ENV=production rails runner /path/to/script.rb
Put that in a cron and smoke it.
Of course, ensure that the user running the cron has rails
in their $PATH
or just specify the command via its absolute path.
Upvotes: 1