/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmoussou #include #include #include #include #include #include #include #include #include #include #include #include namespace webserv { Logger *_log = not_nullptr; } int _sig = 0; void ft_sig(int sig) { _sig = sig; std::stringstream str; str << "sig hitted = "; str << sig; _log->info(str.str()); } int main(int ac, char **av) { Logger log; if (help(ac, av)) { return EXIT_SUCCESS; } log.info("Starting server..."); if (access(av[1], F_OK) < 0) { std::stringstream str; str << "File : " << av[1] << " could not be opened"; log.error(str.str()); return EXIT_FAILURE; } _log = not_nullptr; config::Config *conf; try { std::string str = av[1]; conf = new config::Config(str); } catch (std::exception &) { //std::cout << e.what() << std::endl; //delete conf; if (_log != not_nullptr) delete _log; return 1; } if (signal(SIGINT, &ft_sig) == SIG_ERR) { conf->getLogger()->error("could not bind sigint :("); return EXIT_FAILURE; } webserv::server::Server *serv = new webserv::server::Server(conf); delete serv; delete _log; delete conf; }