views:

19

answers:

1

Hello. I am running rake task(which must be being launched for ~24 hours) but it stops in unexpected time. STRERR is empty. The code which runs the task:

@bucket = Bucket.find(params[:id])
cmd = "#{`which rake`.chomp} bucket:generate[#{@bucket.id}] --trace 2>&1 > #{Rails.root}/log/bucket-#{@network.id}.log &" # 2> #{Rails.root}/log/bucket-#{@network.id}-error.log &"
system(cmd)
flash[:notice] = "Generation started"
redirect_to buckets_path

If I run the task from console it executes normally but task executed from controller stops after some time...

+1  A: 

Requests eventually time out; this is not the right place for such a command.

Instead, try something else to schedule tasks, like cron, or my scheduler daemon gem:

http://www.github.com/ssoroka/scheduler_daemon

If it needs to be driven from the controller, have it update a database entry or even write a file instead.

Steven Soroka
Thank you! It is what i need.
SMiX