Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku local web debug with Intellij IDEA

I'm writing a telegram bot in Java. This bot will be hosted on Heroku in future. For now I'm just building it with Gradle and run it locally with:

heroku local web

command. Is there any way to debug it using Intellij IDEA?

like image 682
Kirill Avatar asked Jan 05 '23 06:01

Kirill


1 Answers

Yes, running heroku local starts a normal Java process under the hood. You can confirm this by running jps (unsure if that works on Windows).

In order to debug with Intellij, you'll need to provide to proper JVM options to enable debugging. For example:

-Xdebug -Xrunjdwp:transport=dt_socket,address=9090,server=y,suspend=n

You can put these in your Procfile or set them as JAVA_OPTS and reference that env var in your Procfile.

Once the heroku local process is started, you can confirm it's working by running:

jdb -attach localhost:9090

Then you can connect a remote debugger in Intellij on localhost:9090.

like image 75
codefinger Avatar answered Jan 09 '23 18:01

codefinger