-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsubsystem.cpp
More file actions
49 lines (35 loc) · 1.43 KB
/
Copy pathsubsystem.cpp
File metadata and controls
49 lines (35 loc) · 1.43 KB
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
39
40
41
42
43
44
45
46
47
48
49
#include <Poco/Util/Application.h>
#include <Poco/ThreadPool.h>
#include <Poco/Net/HTTPServerParams.h>
#include <Poco/Net/ServerSocket.h>
#include <iostream>
#include "subsystem.hpp"
#include "conf.hpp"
#include "factory.hpp"
namespace webcpp {
const int subsystem::DEFAULT_PORT = 8888;
const int subsystem::DEFAULT_MAX_QUEUED = 100;
const int subsystem::DEFAULT_MAX_THREADS = 50;
const std::string subsystem::DEFAULT_SOFTWARE_VERSION = "webcppd/0.1.1";
const char* subsystem::name() const {
return "http::Server";
}
void subsystem::initialize(Poco::Util::Application& app) {
webcpp::conf serverConf(app.config());
unsigned short port = static_cast<unsigned short> (serverConf.getInt("port", subsystem::DEFAULT_PORT));
int maxQueued = serverConf.getInt("maxQueued", subsystem::DEFAULT_MAX_QUEUED);
int maxThreads = serverConf.getInt("maxThreads", subsystem::DEFAULT_MAX_THREADS);
std::string softwareVersion = serverConf.getString("softwareVersion", subsystem::DEFAULT_SOFTWARE_VERSION);
Poco::ThreadPool::defaultPool().addCapacity(maxThreads);
Poco::Net::HTTPServerParams* pars = new Poco::Net::HTTPServerParams;
pars->setMaxQueued(maxQueued);
pars->setMaxThreads(maxThreads);
pars->setSoftwareVersion(softwareVersion);
this->server = new Poco::Net::HTTPServer(new webcpp::factory(serverConf), port, pars);
this->server->start();
}
void subsystem::uninitialize() {
this->server->stop();
delete server;
}
}