Problem shutdown a Netty server

Trustin Lee tlee at redhat.com
Mon Mar 9 07:01:42 EDT 2009


Hi Patrizio,

Please check this Q&A: http://tinyurl.com/899j5w

HTH,

— Trustin Lee, http://gleamynode.net/



On Wed, Mar 4, 2009 at 11:14 PM, Patrizio Munzi
<patrizio.munzi at eris4.com> wrote:
> Hi everybody,
> I'm trying to perform a graceful shutdown of a server.
> Following the advices in the JavaDoc I'm using the code here below:
>
> ---------------------------------------------------------
> public final void shutdown() {
>   channel.disconnect().awaitUninterruptibly();
>   channel.close().awaitUninterruptibly();
>   channel.unbind().awaitUninterruptibly();
>   try {
>       workerExecutor.shutdownNow();
>       workerExecutor.awaitTermination(3600, TimeUnit.SECONDS);
>       bossExecutor.shutdownNow();
>       bossExecutor.awaitTermination(3600, TimeUnit.SECONDS);
>   } catch (InterruptedException e) {
>       // ignore
>   }
> }
> ----------------------------------------------------------
>
> where:
> - channel = serverBootstrap.bind(new InetSocketAddress(port))
> - workerExecutor is the NioServerSocketChannelFactory worker ExecutorService
> reference.
> - boosExecutor is the NioServerSocketChannelFactory boss ExecutorService
> reference.
>
> Now, the previous snippet works correctly if I disconnect my client from the
> server before calling it, but it doesn't work if I call it without
> disconnecting my client.
> In particular shutdown method execution hangs forever waiting for the worker
> thread termination: workerExecutor.awaitTermination(3600, TimeUnit.SECONDS);
>
> Looking a the worker thread object it looks locked on the still connected
> channel.
>
> Is there a way to make it work?
> Is there a way to graceful shutdown a server without first disconnecting its
> clients??
>
> Hope in your help!
> ;-)
>
> Thanks.
>
> --
>
> *Patrizio Munzi*
> Product Specialist
> Viale Bruno Buozzi, 19 - 00197 Roma (Italy)
> tel: +39 06 4543 3540
> fax: +39 06 4543 3587
> mobile: +39 393 7195 164
> mail: patrizio.munzi at eris4.com <mailto:patrizio.munzi at eris4.com>
> web: http://www.eris4.com <http://www.eris4.com/>
> skype: eris4_munzi <skype:eris4_munzi?add>
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>




More information about the netty-users mailing list