static void teardown() { destroyHttpServer(server); destroyHttpRequest(request); }
int main(int argc, char** argv) { // Make current directory=path to execuable char *p = strrchr(argv[0], '/'); if (p != NULL) { *p = '\0'; chdir(argv[0]); } const char *config_file = "config/config.yml"; const char *name = NULL; int c; while ((c = getopt(argc, argv, ":c:n:hv")) != -1) { switch (c) { case 'c': config_file = optarg; break; case 'n': name = optarg; break; case 'h': showHelp(); return 0; case 'v': printf( "SAYAN server - ultra-fast, modular and super-lightweight web server\n" "version : sayan/" VERSION "\n" "build-date : " __DATE__ " " __TIME__ "\n" "project page : https://jacob-zak/projets/sayan-server/\n" ); return 0; case '?': fprintf(stderr, "unkown option: -%c\n\n", optopt); showHelp(); return EXIT_FAILURE; } } if ((argc - optind) > 0) { fprintf(stderr, "too many arguments\n\n"); showHelp(); return EXIT_FAILURE; } /* if (name != NULL) */ /* createNewProject(name); */ PRINT("name, %s", name); // Load config file loadConfig("config/config.yml"); /* const Config *config = getConfig(); */ /* PRINT("Config %d", config->port); */ // Init cache initHttpCache(false); // openLog(getConfig()->config.log_file, WARNING); // Run server /* int procs=get_nprocs(); */ int procs=2; HttpServer *server=initHttpServer(procs, 1024, procs); if(getConfig()->isDaemon) runDaemonServer(server); else runNormalServer(server); // Cleanup destroyHttpServer(server); destroyHttpCache(); return (EXIT_SUCCESS); }