Intellij debugging of separately running Grails instance

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Intellij debugging of separately running Grails instance

Gary Affonso
In my development environment, I've found it's really handy to run a separate interactive grails prompt to do things like clean, run-app, test, dbm-diff, dbm-update, etc.

Both IDE's I've used (Eclipse and Intellij) seem to want to start a new instance of the Grails environment for every operation which is wayyyyy slower than keeping a separate instance spun-up and in interactive mode.

I've been evaluating Intellij for the last month or so and I think I'm going to make the switch permanent.  The downside, though, is that I'm unclear how to setup Intellij for debugging a separately running Grails instance (vs an instance that it starts).  Intellij knows how to debug an instance it starts, I'm hoping to get the same Intellij debugging features but for a separately running Grails instance started from the command line.

I saw some general (not grails specific) info on setting up remote debugging.  Is that my path forward?  Anybody got some pointers about how to do this?

Thanks!

- Gary
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

mjparme
It might be best to just open a feature request to Jetbrains and ask for support for interactive mode http://youtrack.jetbrains.com/issues/IDEA

IMHO, the convenience of the auto setup of debugging for the grails instance IntelliJ starts far out weigh the performance issue of starting a new instance of grails every time you run a grails script. Although, to each his own:-)

I poked around the settings of my grails project and after a cursory glance nothing jumps out at me as this being possible, might get even better help at the intellij discussion forums: http://devnet.jetbrains.net/community/idea/ideacommunity?view=discussions

On Aug 14, 2012, at 10:39 AM, Gary Affonso <[hidden email]> wrote:

> In my development environment, I've found it's really handy to run a separate interactive grails prompt to do things like clean, run-app, test, dbm-diff, dbm-update, etc.
>
> Both IDE's I've used (Eclipse and Intellij) seem to want to start a new instance of the Grails environment for every operation which is wayyyyy slower than keeping a separate instance spun-up and in interactive mode.
>
> I've been evaluating Intellij for the last month or so and I think I'm going to make the switch permanent.  The downside, though, is that I'm unclear how to setup Intellij for debugging a separately running Grails instance (vs an instance that it starts).  Intellij knows how to debug an instance it starts, I'm hoping to get the same Intellij debugging features but for a separately running Grails instance started from the command line.
>
> I saw some general (not grails specific) info on setting up remote debugging.  Is that my path forward?  Anybody got some pointers about how to do this?
>
> Thanks!
>
> - Gary
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

johnrengelman
If you start the grails app with the 'grails-debug' it will pause and wait for a remote debugger to connect. In IntelliJ you can create a new Run Configuration that uses the "Remote" template. The default values match those the grails-debug uses. Run the Remote configuration in IntelliJ and it will connect remotely to the grails instance you started.

--
John

On Tuesday, August 14, 2012 at 11:01 AM, Parmeley, Michael wrote:

It might be best to just open a feature request to Jetbrains and ask for support for interactive mode http://youtrack.jetbrains.com/issues/IDEA

IMHO, the convenience of the auto setup of debugging for the grails instance IntelliJ starts far out weigh the performance issue of starting a new instance of grails every time you run a grails script. Although, to each his own:-)

I poked around the settings of my grails project and after a cursory glance nothing jumps out at me as this being possible, might get even better help at the intellij discussion forums: http://devnet.jetbrains.net/community/idea/ideacommunity?view=discussions

On Aug 14, 2012, at 10:39 AM, Gary Affonso <[hidden email]> wrote:

In my development environment, I've found it's really handy to run a separate interactive grails prompt to do things like clean, run-app, test, dbm-diff, dbm-update, etc.

Both IDE's I've used (Eclipse and Intellij) seem to want to start a new instance of the Grails environment for every operation which is wayyyyy slower than keeping a separate instance spun-up and in interactive mode.

I've been evaluating Intellij for the last month or so and I think I'm going to make the switch permanent. The downside, though, is that I'm unclear how to setup Intellij for debugging a separately running Grails instance (vs an instance that it starts). Intellij knows how to debug an instance it starts, I'm hoping to get the same Intellij debugging features but for a separately running Grails instance started from the command line.

I saw some general (not grails specific) info on setting up remote debugging. Is that my path forward? Anybody got some pointers about how to do this?

Thanks!

- Gary
---------------------------------------------------------------------
To unsubscribe from this list, please visit:



---------------------------------------------------------------------
To unsubscribe from this list, please visit:


Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

rlovtangen
There is also the option to start grails with the usual 'grails run-app', but with the debug config set in JAVA_OPTS. Just like when debugging any other java program.
The reason I prefer this over grails-debug, is that I don't have to connect the debugger right away, but have a running grails application ready to connect a debugger to whenever I need it.
As John explains, the default settings of IntelliJ's run configuration "Remote" is fine, at the moment this is: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

I have an alias set up, like this:
    alias setdebug='export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"'
So after typing 'setdebug' in a shell, a grails application started from that shell will accept debug connections.
You don't want these options in your default JAVA_OPTS, as all java applications will then try to start with debug enabled and fight for the same debug port, and thus only the first application will start.

Ronny

On Aug 15, 2012, at 4:20 PM, John Engelman wrote:

If you start the grails app with the 'grails-debug' it will pause and wait for a remote debugger to connect. In IntelliJ you can create a new Run Configuration that uses the "Remote" template. The default values match those the grails-debug uses. Run the Remote configuration in IntelliJ and it will connect remotely to the grails instance you started.

--
John

On Tuesday, August 14, 2012 at 11:01 AM, Parmeley, Michael wrote:

It might be best to just open a feature request to Jetbrains and ask for support for interactive mode http://youtrack.jetbrains.com/issues/IDEA

IMHO, the convenience of the auto setup of debugging for the grails instance IntelliJ starts far out weigh the performance issue of starting a new instance of grails every time you run a grails script. Although, to each his own:-)

I poked around the settings of my grails project and after a cursory glance nothing jumps out at me as this being possible, might get even better help at the intellij discussion forums: http://devnet.jetbrains.net/community/idea/ideacommunity?view=discussions

On Aug 14, 2012, at 10:39 AM, Gary Affonso <[hidden email]> wrote:

In my development environment, I've found it's really handy to run a separate interactive grails prompt to do things like clean, run-app, test, dbm-diff, dbm-update, etc.

Both IDE's I've used (Eclipse and Intellij) seem to want to start a new instance of the Grails environment for every operation which is wayyyyy slower than keeping a separate instance spun-up and in interactive mode.

I've been evaluating Intellij for the last month or so and I think I'm going to make the switch permanent. The downside, though, is that I'm unclear how to setup Intellij for debugging a separately running Grails instance (vs an instance that it starts). Intellij knows how to debug an instance it starts, I'm hoping to get the same Intellij debugging features but for a separately running Grails instance started from the command line.

I saw some general (not grails specific) info on setting up remote debugging. Is that my path forward? Anybody got some pointers about how to do this?

Thanks!

- Gary
---------------------------------------------------------------------
To unsubscribe from this list, please visit:



---------------------------------------------------------------------
To unsubscribe from this list, please visit:



Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Gary Affonso
Thanks guys!  Perfect.

- Gary

On Aug 15, 2012, at 2:13 PM, Ronny Løvtangen wrote:

> There is also the option to start grails with the usual 'grails run-app', but with the debug config set in JAVA_OPTS. Just like when debugging any other java program.
> The reason I prefer this over grails-debug, is that I don't have to connect the debugger right away, but have a running grails application ready to connect a debugger to whenever I need it.
> As John explains, the default settings of IntelliJ's run configuration "Remote" is fine, at the moment this is: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
>
> I have an alias set up, like this:
>     alias setdebug='export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"'
> So after typing 'setdebug' in a shell, a grails application started from that shell will accept debug connections.
> You don't want these options in your default JAVA_OPTS, as all java applications will then try to start with debug enabled and fight for the same debug port, and thus only the first application will start.
>
> Ronny
>
> On Aug 15, 2012, at 4:20 PM, John Engelman wrote:
>
>> If you start the grails app with the 'grails-debug' it will pause and wait for a remote debugger to connect. In IntelliJ you can create a new Run Configuration that uses the "Remote" template. The default values match those the grails-debug uses. Run the Remote configuration in IntelliJ and it will connect remotely to the grails instance you started.
>>
>> --
>> John
>>
>> On Tuesday, August 14, 2012 at 11:01 AM, Parmeley, Michael wrote:
>>
>>> It might be best to just open a feature request to Jetbrains and ask for support for interactive mode http://youtrack.jetbrains.com/issues/IDEA
>>>
>>> IMHO, the convenience of the auto setup of debugging for the grails instance IntelliJ starts far out weigh the performance issue of starting a new instance of grails every time you run a grails script. Although, to each his own:-)
>>>
>>> I poked around the settings of my grails project and after a cursory glance nothing jumps out at me as this being possible, might get even better help at the intellij discussion forums: http://devnet.jetbrains.net/community/idea/ideacommunity?view=discussions
>>>
>>> On Aug 14, 2012, at 10:39 AM, Gary Affonso <[hidden email]> wrote:
>>>
>>>> In my development environment, I've found it's really handy to run a separate interactive grails prompt to do things like clean, run-app, test, dbm-diff, dbm-update, etc.
>>>>
>>>> Both IDE's I've used (Eclipse and Intellij) seem to want to start a new instance of the Grails environment for every operation which is wayyyyy slower than keeping a separate instance spun-up and in interactive mode.
>>>>
>>>> I've been evaluating Intellij for the last month or so and I think I'm going to make the switch permanent. The downside, though, is that I'm unclear how to setup Intellij for debugging a separately running Grails instance (vs an instance that it starts). Intellij knows how to debug an instance it starts, I'm hoping to get the same Intellij debugging features but for a separately running Grails instance started from the command line.
>>>>
>>>> I saw some general (not grails specific) info on setting up remote debugging. Is that my path forward? Anybody got some pointers about how to do this?
>>>>
>>>> Thanks!
>>>>
>>>> - Gary
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>> http://xircles.codehaus.org/manage_email
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>> http://xircles.codehaus.org/manage_email
>>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Vladimir Havenchyk
Bump.

I'm using grails 2.2.1 with intellij idea 12.1.4, win7 x64. After typing in shell grails-debug or grails-debug run-app I have got
Listening for transport dt_socket at address: 5005

In IDE I added remote with default parameters and try debug, but nothing happens. WAIDW?

debug from IDE works fine.
Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Mihai Glonț
Nothing is wrong, Grails is merely waiting for you to attach a debugger.

On 19/07/13 08:43, Vladimir Havenchyk wrote:

> Bump.
>
> I'm using grails 2.2.1 with intellij idea 12.1.4, win7 x64. After typing in
> shell grails-debug or grails-debug run-app I have got
> Listening for transport dt_socket at address: 5005
>
> In IDE I added remote with default parameters and try debug, but nothing
> happens. WAIDW?
>
> debug from IDE works fine.
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646908.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Vladimir Havenchyk
Mihai Glonț wrote
Nothing is wrong, Grails is merely waiting for you to attach a debugger.

On 19/07/13 08:43, Vladimir Havenchyk wrote:
> Bump.
>
> I'm using grails 2.2.1 with intellij idea 12.1.4, win7 x64. After typing in
> shell grails-debug or grails-debug run-app I have got
> Listening for transport dt_socket at address: 5005
>
> In IDE I added remote with default parameters and try debug, but nothing
> happens. WAIDW?
>
> debug from IDE works fine.
>
>
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646908.html
But I run debug with remote.

Solved after changing debugger mode in IDE to Attach from listener. Thanks, guys
Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

longwa
This is something with Grails that should be changed (some discussion on the dev list shows that most are in favor). The grails -debug or grails-debug commands, by default, have suspend=y which waits until you attach. However, it's more convenient to just run with suspend=n so you can attach when needed.

Just find your grails.sh or grails.bat files in your installation and edit them to change the -debug option to have suspend=n. Then you can startup and attach whenever you want.

-Aaron


On Fri, Jul 19, 2013 at 8:51 AM, Vladimir Havenchyk <[hidden email]> wrote:
Mihai Glonț wrote
> Nothing is wrong, Grails is merely waiting for you to attach a debugger.
>
> On 19/07/13 08:43, Vladimir Havenchyk wrote:
>> Bump.
>>
>> I'm using grails 2.2.1 with intellij idea 12.1.4, win7 x64. After typing
>> in
>> shell grails-debug or grails-debug run-app I have got
>> Listening for transport dt_socket at address: 5005
>>
>> In IDE I added remote with default parameters and try debug, but nothing
>> happens. WAIDW?
>>
>> debug from IDE works fine.
>>
>>
>>
>> --
>> View this message in context:
>> http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646908.html

But I run debug with remote.

Solved after changing debugger mode in IDE to Attach from listener. Thanks,
guys




--
View this message in context: http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646926.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Vladimir Havenchyk
That's perfect. Thank you!

longwa wrote
This is something with Grails that should be changed (some discussion on
the dev list shows that most are in favor). The grails -debug or
grails-debug commands, by default, have suspend=y which waits until you
attach. However, it's more convenient to just run with suspend=n so you can
attach when needed.

Just find your grails.sh or grails.bat files in your installation and edit
them to change the -debug option to have suspend=n. Then you can startup
and attach whenever you want.

-Aaron


On Fri, Jul 19, 2013 at 8:51 AM, Vladimir Havenchyk <
[hidden email]> wrote:

> Mihai Glonț wrote
> > Nothing is wrong, Grails is merely waiting for you to attach a debugger.
> >
> > On 19/07/13 08:43, Vladimir Havenchyk wrote:
> >> Bump.
> >>
> >> I'm using grails 2.2.1 with intellij idea 12.1.4, win7 x64. After typing
> >> in
> >> shell grails-debug or grails-debug run-app I have got
> >> Listening for transport dt_socket at address: 5005
> >>
> >> In IDE I added remote with default parameters and try debug, but nothing
> >> happens. WAIDW?
> >>
> >> debug from IDE works fine.
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646908.html
>
> But I run debug with remote.
>
> Solved after changing debugger mode in IDE to Attach from listener. Thanks,
> guys
>
>
>
>
> --
> View this message in context:
> http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4646926.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Vladimir Havenchyk
One question: is there way for set debug options like for dev grails_opts?
Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

Graeme Rocher-2
Not having suspend can be problematic if you are trying to debug the startup sequence


On Tue, Jul 23, 2013 at 9:58 AM, Vladimir Havenchyk <[hidden email]> wrote:
One question: is there way for set debug options like for dev grails_opts?



--
View this message in context: http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4647083.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource
Reply | Threaded
Open this post in threaded view
|

Re: Intellij debugging of separately running Grails instance

longwa
Graeme,
That's a good point although I think the majority of times I'm debugging a controller or service. I usually just run with -debug all the time and then attach whenever I need to. It seems like running in debug mode doesn't really slow down much until a debugger is actually attached, which is nice.

I believe we discussed having a GRAILS_DEBUG_OPTS flag which would allow an environment variable to control the behavior (such as the port, etc.). I think I may have said I'd submit a pull request for said feature...but I forgot :)

-Aaron


On Tue, Jul 23, 2013 at 5:30 AM, Graeme Rocher <[hidden email]> wrote:
Not having suspend can be problematic if you are trying to debug the startup sequence


On Tue, Jul 23, 2013 at 9:58 AM, Vladimir Havenchyk <[hidden email]> wrote:
One question: is there way for set debug options like for dev grails_opts?



--
View this message in context: http://grails.1312388.n4.nabble.com/Intellij-debugging-of-separately-running-Grails-instance-tp4633187p4647083.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource