#include "includes" #include "EPoll.h" #include "ConsoleService.h" #include "Exception.h" #include "File.h" #include "Log.h" #include "IPAddress.h" #include "HTTPService.h" int main(int argc, char **argv) { try { coreutils::Log(new coreutils::File("/tmp/http.log", O_WRONLY | O_APPEND | O_CREAT, 0644)); coreutils::Log(coreutils::LOG_INFO) << "HTTP Server starting. Build " << __DATE__ << " " << __TIME__; std::string ipAddress = "0.0.0.0"; core::EPoll ePoll; http::HTTPService httpService; core::TCPServerSocket http(ePoll, httpService, core::IPAddress(ipAddress, 8080)); core::ConsoleService consoleService; core::TCPServerSocket console(ePoll, consoleService, core::IPAddress(ipAddress, 1027)); consoleService.commands.add(ePoll, "threads"); consoleService.commands.add(httpService.httpSessions, "sessions"); consoleService.commands.add(console, "consoles"); consoleService.commands.add(consoleService.commands, "help"); ePoll.start(16, 1000); while(true) sleep(300); ePoll.stop(); } catch(coreutils::Exception exception) { std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl; sleep(10); } }