summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpidd.cpp28
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;
};
};