diff options
author | Alan Conway <aconway@apache.org> | 2007-04-26 14:13:14 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2007-04-26 14:13:14 +0000 |
commit | 11cc4a33f5b6ef065445322036a89bb92cffc041 (patch) | |
tree | f3d3e3d0440b01ab8b75745f20519c3887c80a9a /qpid/cpp/src/qpidd.cpp | |
parent | c72af535c741ad0dc057199c5d9e20f1a7341cf4 (diff) | |
download | qpid-python-11cc4a33f5b6ef065445322036a89bb92cffc041.tar.gz |
- 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
Diffstat (limited to 'qpid/cpp/src/qpidd.cpp')
-rw-r--r-- | qpid/cpp/src/qpidd.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
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 <signal.h> #include <iostream> -#include <memory> -#include <cerrno> +#include <fstream> +#include <signal.h> #include "config.h" -#include <unistd.h> #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; }; }; |