Servers
Running Rake tasks
Introduction
You can choose to run your Rake tasks automatically or manually. Running them automatically involves either scheduling them by using the Rake task add-on or by using deploy hooks. Alternatively, you can run them manually on your server.
Scheduling Rake tasks
Read more about Rake Jobs in the documentation.
Using deploy hooks
You can use deploy hooks to execute your rake task at any point of your deployment.
Simply add a bash script to the application that contains the rake task. For example, create the file /.cloud66/scripts/rake_task.sh
as below:
#!/bin/bash
cd $STACK_PATH
bundle exec rake your:task
Then add a deploy_hook to execute the above script on each deploy: create the file .cloud66/deploy_hooks.yml
as below:
production:
after_rails:
- source: /.cloud66/scripts/rake_task.sh
destination: /tmp/rake_task.sh
target: rails
execute: true
run_on: all_servers
apply_during: all
sudo: true
Manually
This is done by starting a terminal connection to your server and executing your rake task.
$ cd $STACK_PATH
$ bundle exec rake your:task