File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ port=8000
22log_path=./log
33queue_size=10
44config_test=Config Loaded, hello from server.cpp!
5+ start_full_server=false
56;
67
78Config manual:
89; signals the end of the config file, anything below ; is ignored. WARNIRNG: has to be placed BELOW the final line
9- = means that the following value will be converted to string
10- //== means that the following value will be treated as int
10+ config_test - test setting for config, far from essential
11+ start_full_server - less hassle while testing logger
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ void Config::loadConfigFileToMap(){
2121 int configFileDescriptor = open (" ./config" , O_RDONLY);
2222 char configFileContents[CONFIG_SIZE];
2323 read (configFileDescriptor, &configFileContents, CONFIG_SIZE);
24+ close (configFileDescriptor);
2425
2526 // Removes everything after ; in config file
2627 configString = std::string (configFileContents);
Original file line number Diff line number Diff line change @@ -16,17 +16,20 @@ int main() {
1616 // Init basic classes
1717 CmdLine cmdline;
1818 Config config;
19- Logger logger (config.get_str_setting (" log_path" ), " Server" );
19+ Logger logger (config.get_str_setting (" log_path" ), " Server" );
20+ // "hello from server.cpp" message, to be removed
21+ logger.info (config.get_str_setting (" config_test" ));
2022
21- // starting watching the incoming port using the router
22- std::string port = config.get_str_setting (" port" );
23- logger.info (" Starting HackTTP at port: " + port);
24-
25- // "hello from server.cpp" message, to be removed
26- logger.info (config.get_str_setting (" config_test" ));
27- Router router ( config.get_int_setting (" queue_size" ) );
28- router.watch (port);
23+ if (config.get_str_setting (" start_full_server" ) == " true" ) {
24+ // starting the full server
25+ std::string port = config.get_str_setting (" port" );
26+ logger.info (" Starting HackTTP at port: " + port);
2927
28+ Router router (config.get_int_setting (" queue_size" ));
29+ router.watch (port);
30+ } else {
31+ logger.info (" Running in test mode" );
32+ }
3033 // cleanup
3134 logger.info (" HackTTP shutting down" );
3235
You can’t perform that action at this time.
0 commit comments