Richard Petri
2017-09-27 09:01:45 UTC
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
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 capnproto+***@googlegroups.com.
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 capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.