summaryrefslogtreecommitdiff
path: root/cpp/src/qpidd.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-06-02 21:20:35 +0000
committerTed Ross <tross@apache.org>2008-06-02 21:20:35 +0000
commit93aa60d35700a912d47719770f294135292359e6 (patch)
treeecb325c417ceefac52f6b327b09fa0d42fb424b6 /cpp/src/qpidd.cpp
parenta4bfd13cf405805b71644959ecd0526e1aeae0f9 (diff)
downloadqpid-python-93aa60d35700a912d47719770f294135292359e6.tar.gz
QPID-1114 Daemon mode improvements
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@662570 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpidd.cpp')
-rw-r--r--cpp/src/qpidd.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp
index 338c5d51f7..d5f570b458 100644
--- a/cpp/src/qpidd.cpp
+++ b/cpp/src/qpidd.cpp
@@ -60,11 +60,13 @@ struct DaemonOptions : public qpid::Options {
bool quit;
bool check;
int wait;
+ std::string piddir;
- DaemonOptions() : qpid::Options("Daemon options"), daemon(false), quit(false), check(false), wait(10)
+ DaemonOptions() : qpid::Options("Daemon options"), daemon(false), quit(false), check(false), wait(10), piddir("/tmp")
{
addOptions()
("daemon,d", optValue(daemon), "Run as a daemon.")
+ ("pid-dir", optValue(piddir, "DIR"), "Directory where port-specific PID file is stored")
("wait,w", optValue(wait, "SECONDS"), "Sets the maximum wait time to initialize the daemon. If the daemon fails to initialize, prints an error and returns 1")
("check,c", optValue(check), "Prints the daemon's process ID to stdout and returns 0 if the daemon is running, otherwise returns 1")
("quit,q", optValue(quit), "Tells the daemon to shut down");
@@ -127,6 +129,8 @@ void shutdownHandler(int /*signal*/){
}
struct QpiddDaemon : public Daemon {
+ QpiddDaemon(std::string pidDir) : Daemon(pidDir) {}
+
/** Code for parent process */
void parent() {
uint16_t port = wait(options->daemon.wait);
@@ -216,7 +220,7 @@ int main(int argc, char* argv[])
// Options that affect a running daemon.
if (options->daemon.check || options->daemon.quit) {
- pid_t pid = Daemon::getPid(options->broker.port);
+ pid_t pid = Daemon::getPid(options->daemon.piddir, options->broker.port);
if (pid < 0)
return 1;
if (options->daemon.check)
@@ -240,7 +244,7 @@ int main(int argc, char* argv[])
if (options->daemon.daemon) {
// Fork the daemon
- QpiddDaemon d;
+ QpiddDaemon d(options->daemon.piddir);
d.fork();
}
else { // Non-daemon broker.