-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal Handling with gracious service stop #223
Comments
Have you taken a look at the signalling example? |
My handler:
I have. But you are just printing out the signal that was given, you do not stop the service... |
Looks like you have a reasonable implementation in play. 👍 |
Capture the service during lambda definition, alternatively call bind on get_method_handler_end. resource->set_method_handler("GET", [service]( ... )
{
service->stop( );
} ); Further Reading See project examples for further details. |
Why would I want to call bind on the get_method_handler and not the signal_handler? |
Apologies I mean sigint_handler. |
The problem I mentioned again in the second reopening issue was that |
Please provide a complete example with build commands. |
Following Error occurs:
The error points to the empty capture list, however |
server->set_signal_handler(SIGINT, [server](const int signum){
server->stop();
} ); See C++11 standard specification for details. |
The error points to an invalid function signature. |
Thank you very much, I am sorry I did not figure that out myself. |
Not at all. Enjoy using Restbed. |
Hi,
I am trying to find a good way to stop the server based on Signals sent.
I tried to write a handler method where I pass A) a const int sig_number and B) a service object to be able to stop the server for example if the Signal is SIGINT or SIGTERM. However, as the standard function signal() as well am I not allowed to pass any other parameters to the function set_method_handler().
How could I stop the server graciously with the stop() method after a Signal was caught?
If you could give me opinions and ideas how a way to accomplish this I would be forever grateful!
EDIT
I declare now the Service Object as static outside of main() making it shared. Yes it kinda work but
server->stop();
inside my signal_handler() terminates the program but throws an exceptionNot sure why and how to handle this.
main() looks as follows:
The text was updated successfully, but these errors were encountered: