summaryrefslogtreecommitdiff
path: root/cpp/src/qpidd.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-04-26 14:13:14 +0000
committerAlan Conway <aconway@apache.org>2007-04-26 14:13:14 +0000
commit058e3c10a63d6512a931b781d0ae16a9e5300086 (patch)
treea345c06851030f20274cb58d1cd3ff5c357ac4e6 /cpp/src/qpidd.cpp
parent95529d52609cfbfc7df137d5bb50a0f7e4a2ddba (diff)
downloadqpid-python-058e3c10a63d6512a931b781d0ae16a9e5300086.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/qpid@532750 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpidd.cpp')
-rw-r--r--cpp/src/qpidd.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp
index d77b472ead..0bcc2c42fb 100644
--- a/cpp/src/qpidd.cpp
+++ b/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;
};
};