From 11cc4a33f5b6ef065445322036a89bb92cffc041 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 26 Apr 2007 14:13:14 +0000 Subject: - docs/man/qpidd.x: explain file and environment configuration. - src/qpidd.cpp: read config from file. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@532750 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpidd.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'qpid/cpp/src/qpidd.cpp') diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp index d77b472ead..0bcc2c42fb 100644 --- a/qpid/cpp/src/qpidd.cpp +++ b/qpid/cpp/src/qpidd.cpp @@ -19,12 +19,10 @@ * */ #include "qpid/broker/Broker.h" -#include #include -#include -#include +#include +#include #include "config.h" -#include #include "qpid/sys/posix/check.h" using namespace qpid; @@ -38,16 +36,20 @@ struct QpiddOptions : public Broker::Options bool help; bool version; bool daemon; + string config; po::options_description desc; QpiddOptions() : - help(false), version(false), daemon(false), desc("Options") + help(false), version(false), daemon(false), + config("/etc/qpidd.conf"), + desc("Options") { using namespace po; desc.add_options() ("daemon,d", optValue(daemon), "Run as a daemon"); Broker::Options::addTo(desc); desc.add_options() + ("config", optValue(config, "FILE"), "Configuation file") ("help,h", optValue(help), "Print help message") ("version,v", optValue(version), "Print version information"); } @@ -60,16 +62,22 @@ struct QpiddOptions : public Broker::Options po::store(po::parse_environment(desc, po::env2option), vm); } catch (const logic_error& e) { - // Make it clear this is an env. var problem, the - // exception from boost::program_options doesn't. - throw logic_error(string(e.what())+" (parsing environment variables)"); + throw logic_error(string("parsing environment variables: ") + + e.what()); + } + po::notify(vm); // So we can use the value of config. + try { + ifstream conf(config.c_str()); + po::store(po::parse_config_file(conf, desc), vm); + } + catch (const logic_error& e) { + throw logic_error(string("parsing config file: ")+ e.what()); } po::notify(vm); }; void usage(ostream& out) const { - out << "Usage: qpidd [OPTIONS]" << endl - << "Start the Qpid AMQP broker." << endl << endl + out << "Usage: qpidd [OPTIONS]" << endl << endl << desc << endl; }; }; -- cgit v1.2.1