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 <[email protected]> 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.
