HTTPServer/main.cpp
2019-03-03 20:41:41 -08:00

42 lines
1.1 KiB
C++

#include "includes"
#include "EPoll.h"
#include "ConsoleServer.h"
#include "HTTPServer.h"
#include "Exception.h"
#include "File.h"
#include "Log.h"
#include "IPAddress.h"
int main(int argc, char **argv) {
try {
core::Log(new core::File("/tmp/http.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
core::Log(core::LOG_INFO) << "HTTP Server starting. Build " << __DATE__ << " " << __TIME__;
std::string ipAddress = "0.0.0.0";
core::EPoll ePoll;
http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8090));
core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027));
console.service->commands.add(ePoll);
console.service->commands.add(http);
console.service->commands.add(console);
ePoll.start(4, 1000);
while(true)
sleep(300);
ePoll.stop();
}
catch(core::Exception exception) {
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
sleep(10);
}
}