Reputation: 7781
I need a way to implement deferred FTP uploads, to different servers, in a Rails3 application. This will be the scenario:
Uploaded folders size will be from 600Mb to 1Gb. They will contain PNG images, little mp4 movies and xml files.
The web server and all the ftp server will be on the same network, same subnet. No need of extra security for now. I'm completely new to asynchronous or delayed jobs. The application will have just one or two users: no need to handle a lot of deploy requests at the same time.
How can I accomplish this task? If you need more info please ask in the comments.
Upvotes: 0
Views: 354
Reputation: 4295
Once you have delayed_job set up, you can set a method to perform in the background while you go about your business. In this case, the deploy method would always be in the background–set by handle_asynchronously
.
class UploadStatus < ActiveRecord::Base
def deploy
# write your ftp loop here
# periodically update this model in the db with the status
end
handle_asynchronously :deploy
end
Now, you can just call @upload_status.deploy()
and it will run in the background.
You could also write a job method, but I think that it makes more sense in an ActiveRecord class because you will be updating the deploy status.
Upvotes: 1