qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r532750 - in /incubator/qpid/trunk/qpid/cpp: docs/man/qpidd.x src/qpidd.cpp
Date Thu, 26 Apr 2007 14:13:15 GMT
Author: aconway
Date: Thu Apr 26 07:13:14 2007
New Revision: 532750

URL: http://svn.apache.org/viewvc?view=rev&rev=532750
Log:

 - docs/man/qpidd.x: explain file and environment configuration. 
 - src/qpidd.cpp: read config from file.

Modified:
    incubator/qpid/trunk/qpid/cpp/docs/man/qpidd.x
    incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp

Modified: incubator/qpid/trunk/qpid/cpp/docs/man/qpidd.x
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/docs/man/qpidd.x?view=diff&rev=532750&r1=532749&r2=532750
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/docs/man/qpidd.x (original)
+++ incubator/qpid/trunk/qpid/cpp/docs/man/qpidd.x Thu Apr 26 07:13:14 2007
@@ -1,5 +1,16 @@
 [NAME]
-qpidd \- the Qpid broker daemon
+qpidd \- the Qpid AMQP broker daemon
 
 [DESCRIPTION]
-.\" Add any additional description here
+
+Start the AMQP broker. The broker options can be specified on the command line (e.g. --worker-threads
10), in an environment variable (e.g. export QPID_WORKER_THREADS=10), or as a line in a configuration
file (e.g. worker-threads=10).
+
+Command line options take precedence over environment variables, which
+take precedence over the config file.
+
+
+
+
+
+
+

Modified: incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp?view=diff&rev=532750&r1=532749&r2=532750
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp Thu Apr 26 07:13:14 2007
@@ -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 @@
     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 @@
             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;
     };
 };



Mime
View raw message