fedechicco@gmail.com wrote:
> Hi Alessandro,
>
>> I give my poor opinion on this. I think this is logically incorrect,
>> because Java is potentially platform independent.
>> Setting some parameters on the platform I'm going to violate this
>> kind of contract, so why don't use C++ ?
>> And sorry I don't understand a GUI implementation to stop a
>> server...I want to do a unix service, I want to start, stop or
>> restart my service with the classic init.d concept...
>
>
> As the other unix daemon, you should use the signals (like SIGKILL) to
> catch events
> from the OS and manage them as you want:
> I don't know how to do that, but I know that you can capture the
> signal of kill and run your own
> events (i.e. do a correct shut-down disconnecting all the clients
> connected and unbinding the ServerSockets,
> and then call your System.exit() )
> I've seen a snippit of code that work in this way for other java
> programs, and I tested it on Winzoz and Linux in the same way.
Use a JVM shutdown hook which I think traps some signals.
@see Runtime.getRuntime().addShutdownHook( Thread hook )
Alex
|