summaryrefslogtreecommitdiff
path: root/qpid/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
commita3c4c567d0d1c616f3f9fcefe12f5c24d71a27c6 (patch)
treef6b3be4e15dfe20585940b60819c6b8f3e157d48 /qpid/cpp/src/qpidd.cpp
parenta45109aa5fdf60dbd26fc80d8d9abba3557c6ecb (diff)
downloadqpid-python-a3c4c567d0d1c616f3f9fcefe12f5c24d71a27c6.tar.gz
QPID-1114 Daemon mode improvements
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@662570 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpidd.cpp')
-rw-r--r--qpid/cpp/src/qpidd.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp
index 338c5d51f7..d5f570b458 100644
--- a/qpid/cpp/src/qpidd.cpp
+++ b/qpid/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.