mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
saner logfile code
testing of ctdbd (This used to be ctdb commit 05789da5818f8b20f04779b0df5125914d9047f6)
This commit is contained in:
parent
e21f69107f
commit
f455d3f44b
@ -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@
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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, ", ")) {
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user