77#include < sys/stat.h>
88#include < unistd.h>
99#include < stdexcept>
10+ #include < sstream>
1011
1112namespace derecho {
1213
@@ -31,7 +32,6 @@ struct option Conf::long_options[] = {
3132 // [DERECHO]
3233 MAKE_LONG_OPT_ENTRY (DERECHO_CONTACT_IP),
3334 MAKE_LONG_OPT_ENTRY (DERECHO_CONTACT_PORT),
34- MAKE_LONG_OPT_ENTRY (DERECHO_LEADER_EXTERNAL_PORT),
3535 MAKE_LONG_OPT_ENTRY (DERECHO_RESTART_LEADERS),
3636 MAKE_LONG_OPT_ENTRY (DERECHO_RESTART_LEADER_PORTS),
3737 MAKE_LONG_OPT_ENTRY (DERECHO_LOCAL_ID),
@@ -182,6 +182,7 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
182182 loadFromFile (node_conf_file.value ());
183183 }
184184 // 2 - load configuration from the command line
185+ bool command_options_present = false ;
185186 int c;
186187 while (1 ) {
187188 int option_index = 0 ;
@@ -194,6 +195,7 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
194195 switch (c) {
195196 case 0 :
196197 this ->config [long_options[option_index].name ] = optarg;
198+ command_options_present = true ;
197199 break ;
198200
199201 case ' ?' :
@@ -203,6 +205,10 @@ Conf::Conf(int argc, char* argv[], std::optional<std::string> group_conf_file,
203205 std::cerr << " ignore unknown commandline code:" << c << std::endl;
204206 }
205207 }
208+ // 3 - warn the user if no options were loaded, since this probably indicates an error
209+ if (!group_conf_file && !node_conf_file && !command_options_present) {
210+ std::cerr << " Warning: derecho.cfg and derecho_node.cfg not found, and no command-line options specified. Falling back to all default configuration options." << std::endl;
211+ }
206212}
207213
208214// should we force the user to call Conf::initialize() by throw an expcetion
@@ -247,6 +253,13 @@ void Conf::loadExtraFile(const std::string& default_file_name, const char* env_v
247253 singleton->loadFromFile (real_file_name);
248254}
249255
256+ std::string Conf::getDebugString () const {
257+ std::stringstream debug_str;
258+ for (const auto & kv_pair : config) {
259+ debug_str << " \t " << kv_pair.first << " = " << kv_pair.second << std::endl;
260+ }
261+ return debug_str.str ();
262+ }
250263
251264const std::string& getConfString (const std::string& key) {
252265 return Conf::get ()->getString (key);
0 commit comments