Background task with rake...or better solution?

Hello everybody,
my new customer wants the new application that stay out of his way. To
make it short he wants to drop images in a folder, and the app should
be so clever to find them, make thumnails and other resized files and
serve them as soon as possible on the backend. I plan to create a
button that start the process and he will have to push it, he’s
methodical but still human, so at times he will probably forget to do
it. To avoid furious phone calls from him I’d like to create an
automated task that will do this job every let’s say 2-3 minutes, so
data will be always served fresh anyway. Is a rake task associated
with a cron job the right way to go? I’ve never had such a strange
requirement, so I can’t think of anything better right now. Any
suggestion will be highly appreciated.
Thanks

JJ Smith

Quoting John S. [email protected]:

with a cron job the right way to go? I’ve never had such a strange
requirement, so I can’t think of anything better right now. Any
suggestion will be highly appreciated.
Thanks

Or a cronjob that uses script/runner to call the Rails code to do it.
Or
any of the background processors with any scheduled task ability. Or if
pure
Ruby code will do it (i.e., no Rails environment needed), call Ruby
script
from cron.

Startup CPU costs are substantial with Rails. If the production server
has
lots of free memory, use a Ruby or Rails program that processes, sleeps
for
2-3 minutes, and processes again. In my experience (my) Rails programs
have
small memory leaks and so I let the script run for an hour, then exit.
Cron
starts a new copy every hour. One advantage is that if the script is
changed,
the new version will start being used within the hour. As the system
matures,
I may stretch it out to restarting once a day instead of once an hour.

There are many ways to do it. I suppose you could use the FAM daemon to
notice the new file and start the processing. Don’t know what kind of
hooks
are available to/from Ruby/Rails code.

HTH,
Jeffrey

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs