meltwater / served

A C++11 RESTful web server library
MIT License
710 stars 174 forks source link

Is served already captured the SIGTERM ? #16

Closed AppleWeng closed 6 years ago

AppleWeng commented 8 years ago

I want to capture SIGTERM signal. But I found when I USE RestfulServer ,I can't capture the SIGTERM signal. Is served already captured the SIGTERM ?Thank you!

cjgdev commented 8 years ago

https://github.com/datasift/served/blob/master/src/served/net/server.cpp#L51

touchpeak commented 7 years ago

Shouldn't this be an option, or a compile-time feature?

We use served as well in a console, and have commented out the signal captures of served.

cjgdev commented 7 years ago

The problem with removing the signal handling is that it would break clients that consume the library and rely on the existing behaviour. The library needs to capture signals to shut down gracefully.

One option would be to make shutdown a responsibility of the library user. I can't remember if there was a good reason not to do this, but it might be as simple as turning server::do_await_stop into a destructor to clean up whenever the server object is destroyed. Of course this would break clients that depend on the existing behaviour.

Another option would be to accept an asio::signal_set as a parameter to the server constructor. Multiple handlers can be registered via successive calls to the member function async_await, but this seems pretty clunky to me.

touchpeak commented 7 years ago

well, at the moment, we work around the issue by implementing the behavior of the server in our own code. works like a charm.