From d818283d39d56204ffe710b6c9b83a2cf497f946 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 2 May 2011 13:46:27 -0400 Subject: Allow changing the log level without restart We will now re-read the confdb debug_level value when processing the monitor_common_logrotate() function, which occurs when the monitor receives a SIGHUP. --- src/monitor/monitor.c | 4 +++- src/monitor/monitor_interfaces.h | 6 ++++-- src/monitor/monitor_sbus.c | 25 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src/monitor') diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 194e74c5..baa9994e 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -122,6 +122,7 @@ struct mt_ctx { bool check_children; bool services_started; struct netlink_ctx *nlctx; + const char *conf_path; }; static int start_service(struct mt_svc *mt_svc); @@ -2372,7 +2373,8 @@ int main(int argc, const char *argv[]) } /* set up things like debug , signals, daemonization, etc... */ - ret = server_setup("sssd", flags, CONFDB_MONITOR_CONF_ENTRY, &main_ctx); + monitor->conf_path = CONFDB_MONITOR_CONF_ENTRY; + ret = server_setup("sssd", flags, monitor->conf_path, &main_ctx); if (ret != EOK) return 2; monitor->ev = main_ctx->event_ctx; diff --git a/src/monitor/monitor_interfaces.h b/src/monitor/monitor_interfaces.h index 8ec6d89b..51ac254c 100644 --- a/src/monitor/monitor_interfaces.h +++ b/src/monitor/monitor_interfaces.h @@ -19,6 +19,8 @@ along with this program. If not, see . */ +#include "sbus/sssd_dbus.h" + /*** Monitor ***/ #define MONITOR_VERSION 0x0001 @@ -53,8 +55,8 @@ int monitor_common_pong(DBusMessage *message, struct sbus_connection *conn); int monitor_common_res_init(DBusMessage *message, struct sbus_connection *conn); -int monitor_common_rotate_logs(DBusMessage *message, - struct sbus_connection *conn); +int monitor_common_rotate_logs(struct confdb_ctx *confdb, + const char *conf_entry); errno_t sss_monitor_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c index 3d0d9d31..632de496 100644 --- a/src/monitor/monitor_sbus.c +++ b/src/monitor/monitor_sbus.c @@ -178,10 +178,11 @@ int monitor_common_res_init(DBusMessage *message, return monitor_common_pong(message, conn); } -int monitor_common_rotate_logs(DBusMessage *message, - struct sbus_connection *conn) +errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb, + const char *conf_path) { - int ret; + errno_t ret; + int old_debug_level = debug_level; ret = rotate_debug_files(); if (ret) { @@ -190,7 +191,23 @@ int monitor_common_rotate_logs(DBusMessage *message, return ret; } - return monitor_common_pong(message, conn); + /* Get new debug level from the confdb */ + ret = confdb_get_int(confdb, NULL, conf_path, + CONFDB_SERVICE_DEBUG_LEVEL, + old_debug_level, + &debug_level); + if (ret != EOK) { + DEBUG(0, ("Error reading from confdb (%d) [%s]\n", + ret, strerror(ret))); + /* Try to proceed with the old value */ + debug_level = old_debug_level; + } + + if (debug_level != old_debug_level) { + DEBUG(0, ("Debug level changed to %d\n", debug_level)); + } + + return EOK; } errno_t sss_monitor_init(TALLOC_CTX *mem_ctx, -- cgit