summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctdb/Makefile.in3
-rw-r--r--ctdb/common/cmdline.c11
-rw-r--r--ctdb/common/ctdb.c21
-rw-r--r--ctdb/direct/ctdbd.c8
-rwxr-xr-xctdb/direct/ctdbd.sh26
-rw-r--r--ctdb/include/ctdb.h2
-rw-r--r--ctdb/include/ctdb_private.h1
-rwxr-xr-xctdb/tests/run_tests.sh1
8 files changed, 69 insertions, 4 deletions
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in
index 81cf72516d..71c45ce6b3 100644
--- a/ctdb/Makefile.in
+++ b/ctdb/Makefile.in
@@ -7,6 +7,7 @@ datarootdir = @datarootdir@
includedir = @includedir@
libdir = @libdir@
bindir = @bindir@
+localstatedir = @localstatedir@
VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@
srcdir = @srcdir@
builddir = @builddir@
@@ -14,7 +15,7 @@ EXTRA_OBJ=@EXTRA_OBJ@
CFLAGS=-g -I$(srcdir)/include -Iinclude -Ilib/util -I$(srcdir) \
-I@tallocdir@ -I@tdbdir@/include -I@libreplacedir@ \
- -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"@SHLIBEXT@\" -DUSE_MMAP=1 @CFLAGS@
+ -DVARDIR=\"$(localstatedir)\" -DUSE_MMAP=1 @CFLAGS@
LIB_FLAGS=@LDFLAGS@ -Llib @LIBS@ -lpopt @INFINIBAND_LIBS@
diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c
index 988fee81e8..4ffb032ed1 100644
--- a/ctdb/common/cmdline.c
+++ b/ctdb/common/cmdline.c
@@ -36,6 +36,7 @@ static struct {
int self_connect;
const char *db_dir;
int torture;
+ const char *logfile;
} ctdb_cmdline = {
.nlist = NULL,
.transport = "tcp",
@@ -43,7 +44,8 @@ static struct {
.socketname = CTDB_PATH,
.self_connect = 0,
.db_dir = NULL,
- .torture = 0
+ .torture = 0,
+ .logfile = NULL
};
@@ -56,6 +58,7 @@ struct poptOption popt_ctdb_cmdline[] = {
{ "debug", 'd', POPT_ARG_INT, &LogLevel, 0, "debug level"},
{ "dbdir", 0, POPT_ARG_STRING, &ctdb_cmdline.db_dir, 0, "directory for the tdb files", NULL },
{ "torture", 0, POPT_ARG_NONE, &ctdb_cmdline.torture, 0, "enable nastiness in library", NULL },
+ { "logfile", 0, POPT_ARG_STRING, &ctdb_cmdline.logfile, 0, "log file location", "filename" },
{ NULL }
};
@@ -80,6 +83,12 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
exit(1);
}
+ ret = ctdb_set_logfile(ctdb, ctdb_cmdline.logfile);
+ if (ret == -1) {
+ printf("ctdb_set_logfile failed - %s\n", ctdb_errstr(ctdb));
+ exit(1);
+ }
+
if (ctdb_cmdline.self_connect) {
ctdb_set_flags(ctdb, CTDB_FLAG_SELF_CONNECT);
}
diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c
index 5c46cd2f65..f2cc65b52b 100644
--- a/ctdb/common/ctdb.c
+++ b/ctdb/common/ctdb.c
@@ -35,6 +35,27 @@ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport)
return 0;
}
+/*
+ choose the logfile location
+*/
+int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile)
+{
+ ctdb->logfile = talloc_strdup(ctdb, logfile);
+ if (ctdb->logfile != NULL) {
+ int fd;
+ close(1);
+ fd = open(ctdb->logfile, O_WRONLY|O_APPEND|O_CREAT, 0666);
+ if (fd == -1) {
+ abort();
+ }
+ if (fd != 1) {
+ dup2(fd, 1);
+ close(fd);
+ }
+ }
+ return 0;
+}
+
/*
set some ctdb flags
diff --git a/ctdb/direct/ctdbd.c b/ctdb/direct/ctdbd.c
index 8274c51531..c5b852ae21 100644
--- a/ctdb/direct/ctdbd.c
+++ b/ctdb/direct/ctdbd.c
@@ -24,6 +24,7 @@
#include "popt.h"
#include "system/wait.h"
#include "cmdline.h"
+#include "../include/ctdb_private.h"
static void block_signal(int signum)
{
@@ -83,6 +84,13 @@ int main(int argc, const char *argv[])
ctdb = ctdb_cmdline_init(ev);
+ /* useful default logfile */
+ if (ctdb->logfile == NULL) {
+ char *name = talloc_asprintf(ctdb, "%s/log.ctdb.%u", VARDIR, ctdb->vnn);
+ ctdb_set_logfile(ctdb, name);
+ talloc_free(name);
+ }
+
/* attach to the list of databases */
s = talloc_strdup(ctdb, db_list);
for (tok=strtok(s, ", "); tok; tok=strtok(NULL, ", ")) {
diff --git a/ctdb/direct/ctdbd.sh b/ctdb/direct/ctdbd.sh
index 7224bdec6d..0d484795a3 100755
--- a/ctdb/direct/ctdbd.sh
+++ b/ctdb/direct/ctdbd.sh
@@ -3,6 +3,28 @@
killall -q ctdbd
echo "Starting 2 ctdb daemons"
-bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.2:9001 &
-bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.1:9001 &
+bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.2:9001
+bin/ctdbd --nlist direct/nodes.txt --listen 127.0.0.1:9001
+
+echo "Testing ping"
+bin/ctdb_control ping || exit 1
+
+echo "Testing status"
+bin/ctdb_control status all || exit 1
+
+echo "Testing statusreset"
+bin/ctdb_control statusreset all || exit 1
+
+echo "Testing debug"
+bin/ctdb_control debug all 5 || exit 1
+bin/ctdb_control debuglevel || exit 1
+bin/ctdb_control debug all 0 || exit 1
+bin/ctdb_control debuglevel || exit 1
+
+echo "Testing map calls"
+bin/ctdb_control getvnnmap 0 || exit 1
+bin/ctdb_control getdbmap 0 || exit 1
+
+killall -q ctdbd
+
diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h
index c73f211f6b..d0af618431 100644
--- a/ctdb/include/ctdb.h
+++ b/ctdb/include/ctdb.h
@@ -259,4 +259,6 @@ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ct
int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode);
+int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile);
+
#endif
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 8bbc35c995..4850003542 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -176,6 +176,7 @@ struct ctdb_context {
const char *name;
const char *db_directory;
const char *transport;
+ const char *logfile;
uint32_t vnn; /* our own vnn */
uint32_t num_nodes;
uint32_t num_connected;
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh
index e628bad800..3125ce8d94 100755
--- a/ctdb/tests/run_tests.sh
+++ b/ctdb/tests/run_tests.sh
@@ -3,6 +3,7 @@
tests/fetch.sh 4 || exit 1
tests/bench.sh 4 || exit 1
tests/test.sh || exit 1
+direct/ctdbd.sh || exit 1
echo "All OK"
exit 0