#include "common/system.h"
#include "common/common.h"
#include "common/logging.h"
+#include "common/logging_conf.h"
+
+#include "ctdb_config.h"
static struct {
const char *debuglevel;
poptContext pc;
struct tevent_context *ev;
const char *ctdb_base;
+ struct conf_context *conf;
+ const char *logging_location;
const char *t;
+ bool ok;
/*
* Basic setup
}
}
+ /*
+ * Configuration file handling
+ */
+
+ ret = ctdbd_config_load(ctdb, &conf);
+ if (ret != 0) {
+ fprintf(stderr, "Failed to setup config file handling\n");
+ goto fail;
+ }
+
/*
* Logging setup/options
*/
- /* Log to stderr when running as interactive */
+ /* Log to stderr (ignoring configuration) when running as interactive */
if (interactive) {
- options.logging = "file:";
+ logging_location = "file:";
+ } else {
+ logging_location = logging_conf_location(conf);
}
- if (strcmp(options.logging, "syslog") != 0) {
+ if (strcmp(logging_location, "syslog") != 0) {
/* This can help when CTDB logging is misconfigured */
syslog(LOG_DAEMON|LOG_NOTICE,
"CTDB logging to location %s",
- options.logging);
+ logging_location);
}
/* Initialize logging and set the debug level */
- if (!ctdb_logging_init(ctdb, options.logging, options.debuglevel)) {
+ ok = ctdb_logging_init(ctdb,
+ logging_location,
+ logging_conf_log_level(conf));
+ if (!ok) {
goto fail;
}
- setenv("CTDB_LOGGING", options.logging, 1);
+ setenv("CTDB_LOGGING", logging_location, 1);
setenv("CTDB_DEBUGLEVEL", debug_level_to_string(DEBUGLEVEL), 1);
- script_log_level = options.script_log_level;
+ script_log_level = debug_level_from_string(
+ ctdb_config.script_log_level);
D_NOTICE("CTDB starting on node\n");
* Cluster setup/options
*/
- ret = ctdb_set_transport(ctdb, options.transport);
+ ret = ctdb_set_transport(ctdb, ctdb_config.transport);
if (ret == -1) {
D_ERR("ctdb_set_transport failed - %s\n", ctdb_errstr(ctdb));
goto fail;
}
- if (options.recovery_lock == NULL) {
+ if (ctdb_config.recovery_lock == NULL) {
D_WARNING("Recovery lock not set\n");
}
- ctdb->recovery_lock = options.recovery_lock;
+ ctdb->recovery_lock = ctdb_config.recovery_lock;
/* tell ctdb what address to listen on */
- if (options.myaddress) {
- ret = ctdb_set_address(ctdb, options.myaddress);
+ if (ctdb_config.node_address) {
+ ret = ctdb_set_address(ctdb, ctdb_config.node_address);
if (ret == -1) {
D_ERR("ctdb_set_address failed - %s\n",
ctdb_errstr(ctdb));
* Database setup/options
*/
- ctdb->db_directory = options.db_dir;
- ctdb->db_directory_persistent = options.db_dir_persistent;
- ctdb->db_directory_state = options.db_dir_state;
+ ctdb->db_directory = ctdb_config.dbdir_volatile;
+ ctdb->db_directory_persistent = ctdb_config.dbdir_persistent;
+ ctdb->db_directory_state = ctdb_config.dbdir_state;
+
+ if (ctdb_config.lock_debug_script != NULL) {
+ ret = setenv("CTDB_DEBUG_LOCKS",
+ ctdb_config.lock_debug_script,
+ 1);
+ if (ret != 0) {
+ D_ERR("Failed to set up lock debugging (%s)\n",
+ strerror(ret));
+ goto fail;
+ }
+ }
+
+ /*
+ * Event setup/options
+ */
+ if (ctdb_config.event_debug_script != NULL) {
+ ret = setenv("CTDB_DEBUG_HUNG_SCRIPT",
+ ctdb_config.event_debug_script,
+ 1);
+ if (ret != 0) {
+ D_ERR("Failed to set up event script debugging (%s)\n",
+ strerror(ret));
+ goto fail;
+ }
+ }
/*
* Legacy setup/options
*/
- ctdb->start_as_disabled = options.start_as_disabled;
- ctdb->start_as_stopped = options.start_as_stopped;
+ ctdb->start_as_disabled = (int)ctdb_config.start_as_disabled;
+ ctdb->start_as_stopped = (int)ctdb_config.start_as_stopped;
/* set ctdbd capabilities */
- if (options.no_lmaster != 0) {
+ if (!ctdb_config.lmaster_capability) {
ctdb->capabilities &= ~CTDB_CAP_LMASTER;
}
- if (options.no_recmaster != 0) {
+ if (!ctdb_config.recmaster_capability) {
ctdb->capabilities &= ~CTDB_CAP_RECMASTER;
}
- ctdb->do_setsched = (options.nosetsched != 1);
+ ctdb->do_setsched = !ctdb_config.no_realtime;
/*
* Miscellaneous setup