aboutsummaryrefslogtreecommitdiffstats
path: root/http_server.h
diff options
context:
space:
mode:
authoripkn <ipknhama@gmail.com>2014-05-02 01:17:49 -0400
committeripkn <ipknhama@gmail.com>2014-05-02 01:17:49 -0400
commit81bd1e1fb6cb2a74c4e372410fb419cfc94991e0 (patch)
treefecebb2f7887cf73f6e6aa1d5ce9ee1d7d3cc57c /http_server.h
parentf8893eb138eae88f35ba752221a02b318d275364 (diff)
downloadcrow-81bd1e1fb6cb2a74c4e372410fb419cfc94991e0.tar.gz
crow-81bd1e1fb6cb2a74c4e372410fb419cfc94991e0.zip
caching datetime string for Date header
Diffstat (limited to 'http_server.h')
-rw-r--r--http_server.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/http_server.h b/http_server.h
index e4893ad..387f2e5 100644
--- a/http_server.h
+++ b/http_server.h
@@ -2,8 +2,10 @@
#include <boost/asio.hpp>
#include <stdint.h>
+#include <atomic>
#include "http_connection.h"
+#include "datetime.h"
// TEST
#include <iostream>
@@ -17,7 +19,11 @@ namespace crow
{
public:
Server(Handler* handler, uint16_t port, uint16_t concurrency = 1)
- : acceptor_(io_service_, tcp::endpoint(asio::ip::address(), port)), socket_(io_service_), handler_(handler), concurrency_(concurrency)
+ : acceptor_(io_service_, tcp::endpoint(asio::ip::address(), port)),
+ socket_(io_service_),
+ signals_(io_service_, SIGINT, SIGTERM),
+ handler_(handler),
+ concurrency_(concurrency)
{
do_accept();
}
@@ -29,6 +35,12 @@ namespace crow
v.push_back(
std::async(std::launch::async, [this]{io_service_.run();})
);
+
+ signals_.async_wait(
+ [&](const boost::system::error_code& error, int signal_number){
+ io_service_.stop();
+ });
+
}
void stop()
@@ -52,8 +64,11 @@ namespace crow
asio::io_service io_service_;
tcp::acceptor acceptor_;
tcp::socket socket_;
+ boost::asio::signal_set signals_;
+
Handler* handler_;
- uint16_t concurrency_ = 1;
- std::string server_name_ = "Flask++/0.1";
+
+ uint16_t concurrency_ = {1};
+ std::string server_name_ = "Crow/0.1";
};
}