faresd / appengine-maven-plugin

Automatically exported from code.google.com/p/appengine-maven-plugin
Apache License 2.0
0 stars 0 forks source link

Stop development server process when terminating #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Deploy an application using m2e in Eclipse with the appengine:devserver goal.
2. Terminate the application in the Eclipse console view.

What is the expected output? What do you see instead?
The development server is still running. I would expect it to terminate.

What version of the product are you using? On what operating system?
1.7.4 and 1.7.5-SNAPSHOT. Windows 8 x64.

Running the maven goal launches two java processes, one of them belonging to 
the Jetty server. When clicking on terminate in the eclipse console view, 
however, the Jetty process is not terminated. Running the application again, 
launches an additional Jetty process and so on.

Original issue reported on code.google.com by geiger....@gmail.com on 22 Feb 2013 at 1:30

GoogleCodeExporter commented 8 years ago
I can reproduce this, but it's non-trivial to fix.  I've actually been working 
on this for a few months when I have some time to spare.  I've tried reducing 
the probability of it happening, but in some cases, yes, this can happen.

Original comment by matts...@google.com on 27 Feb 2013 at 7:44

GoogleCodeExporter commented 8 years ago
I made a few changes to help with this problem, give 1.7.6 a go and let me know 
if it's any better.

Original comment by matts...@google.com on 21 Mar 2013 at 6:18

GoogleCodeExporter commented 8 years ago
Thanks for your efforts! The problem is still present with 1.7.6, though. I 
looked into this some more and the issue seems to be that the Eclipse terminate 
button uses Java Process.destroy(), which, at least on Windows, immediately 
kills any application. Therefore, the Maven process (or appengine-maven) 
probably doesn't get to terminate the Jetty child process.

See the discussion of this on the m2e mailing list and the related 
Jetty/Eclipse issues:
- http://dev.eclipse.org/mhonarc/lists/m2e-users/msg03862.html
- http://jira.codehaus.org/browse/JETTY-208?focusedCommentId=115134
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=64230

There might be two possible ways to approach this:

a) Wrap appengine-maven in another process, which regularly checks for the 
presence of the Maven parent process and, if killed, terminates the Jetty child 
process (and itself).

b) Separate the Jetty lifecycle from application deployment. A Jetty instance 
could be launched automatically at deployment time only if none is running and 
otherwise be reused. Ideally, there would be a way to integrate the development 
server into the Eclipse server view (maybe using GPE?) to enable an easy 
shutdown.

Running Maven from a console and terminating it using Ctrl+C works fine, 
though. Terminating it via a remote debugging connection in Eclipse works, too, 
although this is somewhat cumbersome. We now use this external launch 
configuration in Eclipse:

Command: C:\Windows\System32\cmd.exe
Location: ${workspace_loc:/myproject}
Arguments: /C "start /WAIT cmd /C mvn appengine:devserver -P debug"

Original comment by geiger....@gmail.com on 25 Mar 2013 at 10:40

GoogleCodeExporter commented 8 years ago
I'm adding a devserver_stop goal that will make sure it isn't running.  It 
needs to be called with the same address/port you used to create the server.

Original comment by matts...@google.com on 8 May 2013 at 10:29

GoogleCodeExporter commented 8 years ago
Added in 1.8.0, there is also a step when starting the devserver that will kill 
another server running on the same port.  Reopen if this doesn't solve it!

Original comment by matts...@google.com on 8 May 2013 at 11:17