forked from moulo1982/MyWarehouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUCludeProject.cpp
More file actions
38 lines (31 loc) · 880 Bytes
/
UCludeProject.cpp
File metadata and controls
38 lines (31 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <memory.h>
#include <sys/sysinfo.h>
#include <unistd.h>
#include "http_server.h"
#include "io_service_pool.h"
#include "LogWrapper.h"
#include "client_manager.h"
int main(int argc, char* argv[])
{
//如果有--fork参数,那么将变成守护进程
if (argc == 2)
{
if (!strcmp(argv[1], "--fork"))
{
if (daemon(1, 1) < 0)
{
perror("error daemon.../n");
exit(1);
}
}
}
std::shared_ptr<client_manager> cm(new client_manager);
http_server s(boost::asio::ip::tcp::v4(), 8080, get_nprocs() * 2, [&cm](boost::asio::io_service &io_, request &request_, response &response_)->bool
{
return cm->do_some(io_, request_, response_);
});
std::cout << "Server running at http://0.0.0.0:8080/" << std::endl;
s.run();
return 0;
}