Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Headless Equinox Clean Shutdown?
Headless Equinox Clean Shutdown? [message #103029] Mon, 24 December 2007 18:32 Go to next message
Eclipse UserFriend
Originally posted by: paule.willcode4beer.com

I'm looking at building a startup/shutdown script to run a headless
Equinox from "/etc/init.d".

Is there a "nice" way to shutdown the Equinox instance instead of just
sending a kill?

thx
Re: Headless Equinox Clean Shutdown? [message #103045 is a reply to message #103029] Mon, 24 December 2007 19:35 Go to previous messageGo to next message
Snjezana Peco is currently offline Snjezana PecoFriend
Messages: 789
Registered: July 2009
Senior Member
Java doesn't support Unix signals or similar mechanism for communication
between processes. However, you can use TCP/IP.
When your Equinox instance gets information on some port you choose, you
can smoothly shutdown your instance.
You can write data across network connections using Unix "nc" utility.

Snjeza


Paul wrote:
> I'm looking at building a startup/shutdown script to run a headless
> Equinox from "/etc/init.d".
>
> Is there a "nice" way to shutdown the Equinox instance instead of just
> sending a kill?
>
> thx
>
Re: Headless Equinox Clean Shutdown? [message #103058 is a reply to message #103045] Tue, 25 December 2007 01:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

Actually, even though it is correct you can't add UNIX signal handlers
to Java, it is possible to catch a JVM that is shutting down with:

http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html #addShutdownHook(java.lang.Thread)

If it's not just a daemon thread but a program that also has an RCP UI,
you should also take a look at the considerations in this blog:

http://richclientplatform.blogspot.com/2007/09/sigue-sigue-s igterm_12.html

Snjezana Peco wrote:

> Java doesn't support Unix signals or similar mechanism for communication
> between processes. However, you can use TCP/IP.
> When your Equinox instance gets information on some port you choose, you
> can smoothly shutdown your instance.
> You can write data across network connections using Unix "nc" utility.
>
> Snjeza
>
>
> Paul wrote:
>> I'm looking at building a startup/shutdown script to run a headless
>> Equinox from "/etc/init.d".
>>
>> Is there a "nice" way to shutdown the Equinox instance instead of just
>> sending a kill?
>>
>> thx
>>
Re: Headless Equinox Clean Shutdown? [message #103071 is a reply to message #103058] Tue, 25 December 2007 01:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

Just in case it wasn't clear: the shutdown hook will execute if you send
a SIGTERM to your application. All you have to do is trigger "clean
shutdown" from within the hook, wait for it to complete and return once
it is "safe" for the JVM to proceed with shutdown.

Alexandros Karypidis wrote:

> Actually, even though it is correct you can't add UNIX signal handlers
> to Java, it is possible to catch a JVM that is shutting down with:
>
> http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html #addShutdownHook(java.lang.Thread)
>
>
> If it's not just a daemon thread but a program that also has an RCP UI,
> you should also take a look at the considerations in this blog:
>
> http://richclientplatform.blogspot.com/2007/09/sigue-sigue-s igterm_12.html
>
> Snjezana Peco wrote:
>
>> Java doesn't support Unix signals or similar mechanism for
>> communication between processes. However, you can use TCP/IP.
>> When your Equinox instance gets information on some port you choose,
>> you can smoothly shutdown your instance.
>> You can write data across network connections using Unix "nc" utility.
>>
>> Snjeza
>>
>>
>> Paul wrote:
>>> I'm looking at building a startup/shutdown script to run a headless
>>> Equinox from "/etc/init.d".
>>>
>>> Is there a "nice" way to shutdown the Equinox instance instead of
>>> just sending a kill?
>>>
>>> thx
>>>
Re: Headless Equinox Clean Shutdown? [message #103156 is a reply to message #103045] Wed, 02 January 2008 20:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paule.willcode4beer.com

Thanks, I'm just trying to make sure Jetty can do a proper clean-up on
shutdown. Guess, I'll just emulate the 'ol Tomcat shutdown port :-)
Re: Headless Equinox Clean Shutdown? [message #103168 is a reply to message #103058] Wed, 02 January 2008 20:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paule.willcode4beer.com

point taken but, regarding Equniox, is it ok to just kill it?
usually, a platform comes with some means to conduct a clean shutdown.
this makes it look like I'll need to submit a patch to the equinox project
to provide lifecycle methods.
Re: Headless Equinox Clean Shutdown? [message #103173 is a reply to message #103156] Wed, 02 January 2008 20:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paule.willcode4beer.com

I forgot to ask, is it ok to just kill Equinox?

Eclipse doesn't seem to like it when you do that.

Is there no hook/command to tell the Equinox platform to shutdown
gracefully?
Re: Headless Equinox Clean Shutdown? [message #103187 is a reply to message #103029] Wed, 02 January 2008 21:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: paule.willcode4beer.com

Answering my own question.
I've dug through the source a bit and concluded that the simplest thing to
do is to create a start-up class.
This will call the "startup()" method in
'org.eclipse.core.runtime.adaptor.EclipseStarter'. It will then listen on
a port for a shutdown command and (when received), call the "shutdown()"
on the EclipseStarter class.

This should provide a "clean" way to shutdown an Equinox instance. It will
also allow lifecycle events to proceed in the normal way for Equinox and
all bundles that are installed.

I might also, have it re-route the io for the FrameworkConsole in order to
support a remote equinox console.
Headless Startup/Shutdown Scripts [message #103200 is a reply to message #103029] Fri, 04 January 2008 00:48 Go to previous message
Paul Davis is currently offline Paul DavisFriend
Messages: 6
Registered: July 2009
Junior Member
I've created a project on google code to address running Equinox headless
as well as ensuring that it can perform a clean shutdown.

http://code.google.com/p/equinox-headless-service/downloads/ list

It's the first revision (read no security, weak error handling) so please
be gentle.

Basically, the concept is to use a bootstrap class to start the service
and keep it running. It listens on a port to receive STATUS and SHUTDOWN
commands.
Previous Topic:java.lang.NoClassDefFoundError: org/xml/sax/SAXException
Next Topic:Update Manager vs. Equinox P2
Goto Forum:
  


Current Time: Wed Nov 26 11:51:37 GMT 2014

Powered by FUDForum. Page generated in 0.02664 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software