When I am using Capistrano to deploy Rails application, there will be a case where I need to change data on production. I usually do that by creating a rake task that will run series of commands that will help me update the data.
It will be easier if I can update that through my local CLI instead of login to the server, go to the project folder, and run the command from there.
These are few steps that I follow to achieve it.
1. Make sure the rake task that you want to run is ready on the production server
You have to deploy the rake task that you want to run from your local CLI before creating the capistrano task that runs rake task.
2. Create a Capistrano task that is used to run rake from the CLI
I am using Capistrano version 3.10. If I see
Capfile after I setup capistrano,
I’ll see that there is a line that defines Capistrano loads custom task from
I can start create a custom rake file inside the
lib/capistrano/tasks folder. I set the task name as
3. Run the task through your CLI
I can run any task from my local by running
cap (staging/production) run_rake:invoke task=task_name from my local.