thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spencer Brown <>
Subject Re: C++ TNonblockingserver graceful exit
Date Mon, 17 Aug 2015 14:50:58 GMT
Write a small C++ client that connects to your server on localhost and calls server.shutdown().
Run it in another terminal window.

This is not exactly "pressing escape" but it will work. 

If you really need the "press escape" behavior in a single window, change your server launcher
code to start the server in another process, then listen for console input and when you get
the escape, run the above mentioned client and exit after a couple of seconds. 

> On Aug 17, 2015, at 8:50 AM, Alexandre Iglesias <> wrote:
> Hello, thrift mailing list!
> When using a TNonBlockingServer in the following way (console application in C++) in
the main thread, can I implement something that would shut it down when pressing escape ?
> boost::shared_ptr<ThriftGoatServiceHandler> handler(new ThriftGoatServiceHandler());
> boost::shared_ptr<TProcessor> processor(new GoatThriftServiceProcessor(handler));
> boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
> TNonblockingServer server(processor, protocolFactory, port);
> try
> {
>    server.serve();
> }

View raw message