For Cloud Foundry to automatically invoke a Rake task while a Ruby or Ruby on Rails app is deployed, you must do the following:
- Include the Rake task in your app.
- Configure the application start command using the
command
attribute in the application manifest.
Use the following example to invoke a Rake database migration task at application startup:
-
Create a file with the Rake task name and the extension
.rake
, and store it in thelib/tasks
directory of your application. -
Add the following code to your rake file:
This Rake task limits an idempotent command to the first instance of a deployed application.
-
Add the task to the
manifest.yml
file with thecommand
attribute, referencing the idempotent commandrake db:migrate
chained with a start command.
Content feedback and comments