mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #141 from rayburgemeestre/master
expose server stop() in Crow app to allow shutdown other than signal.
This commit is contained in:
commit
85c3494200
@ -94,14 +94,28 @@ namespace crow
|
|||||||
#ifdef CROW_ENABLE_SSL
|
#ifdef CROW_ENABLE_SSL
|
||||||
if (use_ssl_)
|
if (use_ssl_)
|
||||||
{
|
{
|
||||||
ssl_server_t server(this, bindaddr_, port_, &middlewares_, concurrency_, &ssl_context_);
|
ssl_server_ = std::move(std::unique_ptr<ssl_server_t>(new ssl_server_t(this, bindaddr_, port_, &middlewares_, concurrency_, &ssl_context_)));
|
||||||
server.run();
|
ssl_server_->run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
server_t server(this, bindaddr_, port_, &middlewares_, concurrency_, nullptr);
|
server_ = std::move(std::unique_ptr<server_t>(new server_t(this, bindaddr_, port_, &middlewares_, concurrency_, nullptr)));
|
||||||
server.run();
|
server_->run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
#ifdef CROW_ENABLE_SSL
|
||||||
|
if (use_ssl_)
|
||||||
|
{
|
||||||
|
ssl_server_->stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
server_->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +211,11 @@ namespace crow
|
|||||||
Router router_;
|
Router router_;
|
||||||
|
|
||||||
std::tuple<Middlewares...> middlewares_;
|
std::tuple<Middlewares...> middlewares_;
|
||||||
|
|
||||||
|
#ifdef CROW_ENABLE_SSL
|
||||||
|
std::unique_ptr<ssl_server_t> ssl_server_;
|
||||||
|
#endif
|
||||||
|
std::unique_ptr<server_t> server_;
|
||||||
};
|
};
|
||||||
template <typename ... Middlewares>
|
template <typename ... Middlewares>
|
||||||
using App = Crow<Middlewares...>;
|
using App = Crow<Middlewares...>;
|
||||||
|
Loading…
Reference in New Issue
Block a user