Use a custom start command
Note: This guide uses the Cloud Foundry CLI version 6. The instructions below are not compatible with any cf version < 6. Click here to read how to install the cf CLI v6.
What is a custom start command?
When you need to run a script or a rake task at the end of your deployment process, you will have to customize your push command. This command will be executed on each application server.
Customizing a start command
Customizing a start command is no rocket-science. Adding an option for your push command, for example for your Ruby on Rails database migration, looks somewhat like this:
cf push -c ‘bundle exec rake db:migrate’
You might get in trouble if you have more than one instance, because this will run the task on each application instance. To prevent this you can just scale your application down to one instance within the same command by adding an additional option:
cf push -c ‘bundle exec rake db:migrate’ -i 1
Don’t forget!
Each following push command will execute the last customized command. You can reset your customization with:
cf push -c ‘null’
Please sign in to leave a comment.
Comments
0 comments