Hi Richard,

The EZ classes are really designed for the most basic use case. The intent
is that if you're doing anything more complicated, you skip them and use
the underlying APIs.

In particular you'll want to use kj::setupAsyncIo() to get your initial I/O
context, and then use capnp::TwoPartyServer and capnp::TwoPartyClient in
<capnp/rpc-twoparty.h>.

Honestly I should probably deprecate the EZ classes altogether and direct
people to these interfaces instead... it's only a couple extra lines to set
up and then you have full flexibility.

-Kenton

On Wed, Sep 27, 2017 at 2:01 AM, Richard Petri <[email protected]> wrote:

> Hello,
>
> I'm trying to implement a graceful shutdown of a server if SIGTERM is
> received. I'm new to capnproto, so I'm not sure on how to approach this.
> Looking through the source, the UnixEventPort seems to be a way to catch
> signals, but from what I can see this won't work together with the
> EzRPCServer. For example, if a adapt the simple server example from
> waiting forever like this
>
>     kj::NEVER_DONE.wait(waitScope);
>
> and instead wait like this:
>
>     kj::UnixEventPort::captureSignal(SIGTERM);
>     kj::UnixEventPort evport;
>     kj::Promise<siginfo_t> p = evport.onSignal(SIGTERM).wait(waitScope);
>     std::cout << "Shutting down server..." << std::endl;
>
> it appears to catch the signal (the server won't terminate when SIGTERM
> arrives, so the default signal handler isn't called at least), but will
> never handle it / fulfill the promise. I guess I don't understand enough
> about the EventPorts, EventLoops, etc., and how this all works together.
>
> Looking into the source, the AsyncIoContext created by an EzRpcServer
> can access the eventport, but this is hidden.
>
> Is there an easy way to achieve this that I'm missing, or will I have to
> implement my own RpcServer spinoff?
>
> Best Regards,
> Richard
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> Visit this group at https://groups.google.com/group/capnproto.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to