Deploying to Heroku

This sub-generator allows to deploy automatically your JHipster application to the Heroku cloud.

Limitations

This sub-generator has a few caveats:

  • If your application takes longer than 60 seconds to boot, Heroku will kill the process. You can request a higher boot limit by contacting Heroku Support.
  • If your application is killed by Heroku when your Liquibase changelog is being applied, your database will be marked as "locked" by Liquibase. You will need to manually clean the lock table (see below)

Running the sub-generator

Before running the sub-generator, you need to install the Heroku toolbelt, and have a Heroku account created.

Be sure that you got logged on Heroku following the documentation, in section getting started:

$ heroku login
Enter your Heroku credentials.
Email: YOUR_EMAIL
Password (typing will be hidden): YOUR_PASSWORD
Authentication successful.

To deploy your application to Heroku, type:

yo jhipster:heroku

This should package your application in "production" mode, create an Heroku application (with a Postgresql database), upload your code, and start the application.

Please be aware that your application must start under 60 seconds, or it will be killed. Depending on the platform load, starting under 60 seconds is of course not guaranteed!

Updating your deployed application

Preparing a new deployment

When your application is already deployed, you can prepare a new deployment by typing:

mvn package -Pprod -DskipTests

Or when using gradle:

./gradlew -Pprod bootRepackage -x test

Pushing to production

Note: This assumes you have run the generator on the machine you are executing this command from. If you have not, you will need to first run heroku plugins:install https://github.com/heroku/heroku-deploy.

To push to production, type:

heroku deploy:jar --jar target/*.war

Or when using gradle:

heroku deploy:jar --jar build/libs/*war

Troubleshooting

If your app is hanging at boot-time with the message "Configuring Liquibase", then make sure you have a local Postgres client installed and run the following command:

$ heroku pg:psql -c "update databasechangeloglock set locked=false;"

Heroku has a default boot-timeout limit of 60 seconds. If your Liquibase configuration takes longer than this, Heroku will kill the process, which leaves the database in a locked state. If the problem is persistent, try contacting Heroku Support to request a longer boot limit for your app.

More information