You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Shawn Yarbrough <sh...@omnisci.com> on 2019/07/17 00:01:23 UTC

how to stop serving?

I have a working Thrift server on C++ and Linux. Clients can communicate
with the server and everything works well. The C++ server class is a
TThreadedServer running serve().

What is the correct way to shut down this server?

The question seems obvious but I haven't been able to find an answer in the
Thrift documentation. This example code suggests that it is possible to
exit the server (there is a cout "Done") but without explanation of how:

https://gitbox.apache.org/repos/asf?p=thrift.git;a=blob;f=tutorial/cpp/CppServer.cpp;hb=HEAD

Shawn Y.

Re: how to stop serving?

Posted by Shawn Yarbrough <sh...@omnisci.com>.
Thanks, Jim. Calling stop() from another thread does the trick. Problem solved.

Shawn Y.

On Jul 16, 2019, at 7:15 PM, James E. King III <jk...@apache.org> wrote:

Assuming you are using Thrift 0.9.3 or later you can call stop() on
the C++ TThreadedServer to stop the server safely.
If you look at the comments in
lib/cpp/src/thrift/server/TServerFramework.h it may provide more
context.
The example you posted is likely terminated manually by signal (^C for
example) and rather uncleanly at that.
Typically one would spin off a thread to handle the thrift server
duties, and use another thread to stop() the thrift server.

- Jim

On Tue, Jul 16, 2019 at 8:02 PM Shawn Yarbrough
<sh...@omnisci.com> wrote:
> 
> I have a working Thrift server on C++ and Linux. Clients can communicate
> with the server and everything works well. The C++ server class is a
> TThreadedServer running serve().
> 
> What is the correct way to shut down this server?
> 
> The question seems obvious but I haven't been able to find an answer in the
> Thrift documentation. This example code suggests that it is possible to
> exit the server (there is a cout "Done") but without explanation of how:
> 
> https://gitbox.apache.org/repos/asf?p=thrift.git;a=blob;f=tutorial/cpp/CppServer.cpp;hb=HEAD
> 
> Shawn Y.

Re: how to stop serving?

Posted by "James E. King III" <jk...@apache.org>.
Assuming you are using Thrift 0.9.3 or later you can call stop() on
the C++ TThreadedServer to stop the server safely.
If you look at the comments in
lib/cpp/src/thrift/server/TServerFramework.h it may provide more
context.
The example you posted is likely terminated manually by signal (^C for
example) and rather uncleanly at that.
Typically one would spin off a thread to handle the thrift server
duties, and use another thread to stop() the thrift server.

- Jim

On Tue, Jul 16, 2019 at 8:02 PM Shawn Yarbrough
<sh...@omnisci.com> wrote:
>
> I have a working Thrift server on C++ and Linux. Clients can communicate
> with the server and everything works well. The C++ server class is a
> TThreadedServer running serve().
>
> What is the correct way to shut down this server?
>
> The question seems obvious but I haven't been able to find an answer in the
> Thrift documentation. This example code suggests that it is possible to
> exit the server (there is a cout "Done") but without explanation of how:
>
> https://gitbox.apache.org/repos/asf?p=thrift.git;a=blob;f=tutorial/cpp/CppServer.cpp;hb=HEAD
>
> Shawn Y.