I need a way to implement deferred FTP uploads, to different servers, in a Rails3 application. This will be the scenario:
- The user builds a folder full of files and subfolders, with a simple Rails3 CMS (DONE)
- When the user ends his work, he would click on a deploy button.
- The system takes the control and stores the user request.
- The systen gives the control back to the user, this way he can work on other stuff.
- At the same time the system initiates 10 FTP uploads of the same folder.
- When an upload ends it will store its status somewhere.
- The user can see the deployment status, at any time, by going on a specific page.
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.
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.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.