Home » Eclipse Projects » Eclipse Platform » Graceful shutdown of Java Applications
Graceful shutdown of Java Applications [message #248642] |
Thu, 03 June 2004 00:03  |
Eclipse User |
|
|
|
I've added a graceful shutdown feature to one of my Java Apps, using:
Runtime.getRuntime().addShutdownHook(...)
It works fine if I start the application from the command line, and then
terminate it with a Ctrl-C
But when I run the same application from Eclipse, and then hit the terminate
button, it does the same old unclean stop as before.
How can I stop my Java application, within Eclipse, in a way that my
shutdown hook is invoked?
Regards
Daniel
|
|
| | | | | |
Re: Graceful shutdown of Java Applications [message #249143 is a reply to message #248889] |
Thu, 03 June 2004 17:29   |
Eclipse User |
|
|
|
Originally posted by: eclipse.rizzoweb.com
Eric Rizzo wrote:
> Nice. See the bug. See them blow it off and ignore it for the past
> year. See Eclipse continue to pile up unaddressed issues while
> relentlessly pursuing additional features and new L&F. See Eclipse
> turn into MS Word...
Rich Kulp wrote:
> That's not fair. They do fix many bugs. They've been quite responsive
> for me. They stated in the bug that they don't know how to fix it. So
> how can they then fix it if they don't know how.
OK, so I was in a bit of a cynical mood this morning. The Eclipse team
has impressed even me with responsiveness to *some* bug reports and user
community requests.
That said, I guess my point, which was perhaps lost in my harsh cynical
tone, is that I think Eclipse is skating on the verge of Micro$oft
territory, where new whiz-bang features take undue precedence over
fixing known, documented, painful bugs/issues. It is not as bad as Word,
etc. but I think with 3.0 it is dangerously close.
Dave Wegener wrote:
> Lighten up. It doesn't appear as though there is much Eclipse can do
> about it. Based on Sun's bug database entry for 4485742, it is a feature
> of the VM to not guarantee that shutdown hooks are called when
> Process.destroy() is used to stop an external VM. There is apparently no
> alternative way of stopping the VM. Calling Runtime.exit() in the target
> VM will cause the shutdown hooks to run. However, you can't call this
> method from the launching VM.
As I said, my mood was not the most amicable when I wrote my comment and
thus I could have chosen better tone and words.
That said, I've learned that the response "There is nothing I can do" is
almost never really the truth in software development. I'm sure the
(sincerely) brilliant people on the Eclipse team could come up with a
solution (perhaps temporary, perhaps ugly) if the bug were a priority to
them. Fact is, it is not a priority, and it is the assignment of
priorities that I am starting to disagree with more and more. I'd rather
see more of the outstanding bugs knocked out before whiz-bang features
are added (one example, the new L&F, cost resources to develop,
resources that could have been used to fix bugs like the shutdown hooks
one that started this discussion).
I hope this is a more amiable response that makes my point more
effectively. I apologize for the harsh message earlier that incited
defensive, rather than receptive, attitudes.
Eric
|
|
|
Re: Graceful shutdown of Java Applications - finding PID [message #251014 is a reply to message #249143] |
Wed, 09 June 2004 10:59   |
Eclipse User |
|
|
|
Thanks for all the replies, even if some slightly off topic :)
I'm still wondering how other developers working on J2EE get around this
bug. It's fairly essential that between debug runs the app releases the
resources properly (in my case, if it doesn't our JMS server crashes).
I've kinda followed the suggestion on the bug page of lauching my app using
'java' rather than 'javaw'. It doesn't make any DOS console appear, but at
least I can easily identify the java process in the Task Manager and then
using a seperate DOS window I can 'taskkill' the right PID. That does invoke
my shutdown hooks and keeps my JMS server running happily.
Still, it's a tedious task. Having to lookup the PID each time I want to
shutdown the app. I'm wondering if anyone has an idea on how to automate
this. I've written startup scripts to do in in Linux (where the app is to be
deployed) but I'd like to have it for Windows as well, while using Eclipse.
I've also tried getting the PID from the app itself, but that would require
messing with JNI.
So, resuming: Is there an automatic way of getting the PID of a java process
started by Eclipse?
Regards
Daniel Farinha
PS: I don't want to get into the politics of Eclipse bug priorities, but
woudn't it be feasible for Eclipse to keep the PID of the process and make a
call to TASKKILL while in DOS/Windows or KILL while in Linux for graceful
shutdowns? Or if it goes against the rules (platform independence) then
perhaps some sort of a plugin?
"Eric Rizzo" <eclipse@rizzoweb.com> wrote in message
news:c9o4o7$ebp$1@eclipse.org...
> Eric Rizzo wrote:
>
> > Nice. See the bug. See them blow it off and ignore it for the past
> > year. See Eclipse continue to pile up unaddressed issues while
> > relentlessly pursuing additional features and new L&F. See Eclipse
> > turn into MS Word...
>
> Rich Kulp wrote:
> > That's not fair. They do fix many bugs. They've been quite responsive
> > for me. They stated in the bug that they don't know how to fix it. So
> > how can they then fix it if they don't know how.
>
> OK, so I was in a bit of a cynical mood this morning. The Eclipse team
> has impressed even me with responsiveness to *some* bug reports and user
> community requests.
> That said, I guess my point, which was perhaps lost in my harsh cynical
> tone, is that I think Eclipse is skating on the verge of Micro$oft
> territory, where new whiz-bang features take undue precedence over
> fixing known, documented, painful bugs/issues. It is not as bad as Word,
> etc. but I think with 3.0 it is dangerously close.
>
>
> Dave Wegener wrote:
> > Lighten up. It doesn't appear as though there is much Eclipse can do
> > about it. Based on Sun's bug database entry for 4485742, it is a
feature
> > of the VM to not guarantee that shutdown hooks are called when
> > Process.destroy() is used to stop an external VM. There is apparently
no
> > alternative way of stopping the VM. Calling Runtime.exit() in the
target
> > VM will cause the shutdown hooks to run. However, you can't call this
> > method from the launching VM.
>
> As I said, my mood was not the most amicable when I wrote my comment and
> thus I could have chosen better tone and words.
> That said, I've learned that the response "There is nothing I can do" is
> almost never really the truth in software development. I'm sure the
> (sincerely) brilliant people on the Eclipse team could come up with a
> solution (perhaps temporary, perhaps ugly) if the bug were a priority to
> them. Fact is, it is not a priority, and it is the assignment of
> priorities that I am starting to disagree with more and more. I'd rather
> see more of the outstanding bugs knocked out before whiz-bang features
> are added (one example, the new L&F, cost resources to develop,
> resources that could have been used to fix bugs like the shutdown hooks
> one that started this discussion).
>
> I hope this is a more amiable response that makes my point more
> effectively. I apologize for the harsh message earlier that incited
> defensive, rather than receptive, attitudes.
>
> Eric
|
|
|
Re: Graceful shutdown of Java Applications - finding PID [message #295741 is a reply to message #251014] |
Tue, 06 December 2005 12:28  |
Eclipse User |
|
|
|
Originally posted by: stefan.baramov.trx.com
I have just recently stumbled on this bug investigating a very similar
problem. If I can make a suggestion, it would have been nice if the
console (of the debug perspective) allows to submit special control
characters. For example if I am able to submit Ctrl+C this will cause
the JVM to gracefully shutdown.
I voted for the bug with the hope someone will pay attention to it.
Daniel Farinha wrote:
> Thanks for all the replies, even if some slightly off topic :)
>
> I'm still wondering how other developers working on J2EE get around this
> bug. It's fairly essential that between debug runs the app releases the
> resources properly (in my case, if it doesn't our JMS server crashes).
>
> I've kinda followed the suggestion on the bug page of lauching my app using
> 'java' rather than 'javaw'. It doesn't make any DOS console appear, but at
> least I can easily identify the java process in the Task Manager and then
> using a seperate DOS window I can 'taskkill' the right PID. That does invoke
> my shutdown hooks and keeps my JMS server running happily.
>
> Still, it's a tedious task. Having to lookup the PID each time I want to
> shutdown the app. I'm wondering if anyone has an idea on how to automate
> this. I've written startup scripts to do in in Linux (where the app is to be
> deployed) but I'd like to have it for Windows as well, while using Eclipse.
>
> I've also tried getting the PID from the app itself, but that would require
> messing with JNI.
>
> So, resuming: Is there an automatic way of getting the PID of a java process
> started by Eclipse?
>
> Regards
>
> Daniel Farinha
>
> PS: I don't want to get into the politics of Eclipse bug priorities, but
> woudn't it be feasible for Eclipse to keep the PID of the process and make a
> call to TASKKILL while in DOS/Windows or KILL while in Linux for graceful
> shutdowns? Or if it goes against the rules (platform independence) then
> perhaps some sort of a plugin?
>
> "Eric Rizzo" <eclipse@rizzoweb.com> wrote in message
> news:c9o4o7$ebp$1@eclipse.org...
>> Eric Rizzo wrote:
>>
>>> Nice. See the bug. See them blow it off and ignore it for the past
>>> year. See Eclipse continue to pile up unaddressed issues while
>>> relentlessly pursuing additional features and new L&F. See Eclipse
>>> turn into MS Word...
>> Rich Kulp wrote:
>>> That's not fair. They do fix many bugs. They've been quite responsive
>>> for me. They stated in the bug that they don't know how to fix it. So
>>> how can they then fix it if they don't know how.
>> OK, so I was in a bit of a cynical mood this morning. The Eclipse team
>> has impressed even me with responsiveness to *some* bug reports and user
>> community requests.
>> That said, I guess my point, which was perhaps lost in my harsh cynical
>> tone, is that I think Eclipse is skating on the verge of Micro$oft
>> territory, where new whiz-bang features take undue precedence over
>> fixing known, documented, painful bugs/issues. It is not as bad as Word,
>> etc. but I think with 3.0 it is dangerously close.
>>
>>
>> Dave Wegener wrote:
>>> Lighten up. It doesn't appear as though there is much Eclipse can do
>>> about it. Based on Sun's bug database entry for 4485742, it is a
> feature
>>> of the VM to not guarantee that shutdown hooks are called when
>>> Process.destroy() is used to stop an external VM. There is apparently
> no
>>> alternative way of stopping the VM. Calling Runtime.exit() in the
> target
>>> VM will cause the shutdown hooks to run. However, you can't call this
>>> method from the launching VM.
>> As I said, my mood was not the most amicable when I wrote my comment and
>> thus I could have chosen better tone and words.
>> That said, I've learned that the response "There is nothing I can do" is
>> almost never really the truth in software development. I'm sure the
>> (sincerely) brilliant people on the Eclipse team could come up with a
>> solution (perhaps temporary, perhaps ugly) if the bug were a priority to
>> them. Fact is, it is not a priority, and it is the assignment of
>> priorities that I am starting to disagree with more and more. I'd rather
>> see more of the outstanding bugs knocked out before whiz-bang features
>> are added (one example, the new L&F, cost resources to develop,
>> resources that could have been used to fix bugs like the shutdown hooks
>> one that started this discussion).
>>
>> I hope this is a more amiable response that makes my point more
>> effectively. I apologize for the harsh message earlier that incited
>> defensive, rather than receptive, attitudes.
>>
>> Eric
>
>
|
|
|
Goto Forum:
Current Time: Sat May 31 11:01:36 EDT 2025
Powered by FUDForum. Page generated in 0.05186 seconds
|