From e301877b16b1ecb33ccb98874261643ddf738ac9 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 26 Feb 2020 11:13:06 +0100 Subject: [PATCH] Follow-up to 12d14aa, configurable auto-reload of .conf files Signed-off-by: Joachim Nilsson --- README.md | 14 ++++++++++++++ configure.ac | 7 +++++++ src/conf.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 68056d31..9b6e09e1 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,20 @@ from the kernel, leaving only warnings and errors. For other kernel command line parameters, see [docs/build.md](docs/build.md#recovery). +**Automatic Reload** + +By default, Finit monitors `/etc/finit.d/` and `/etc/finit.d/enabled/` +registering any changes to `.conf` files. To activate a change the user +must call `initctl reload`, which reloads all modified files, stops any +removed services, starts new ones, and restarts any modified ones, with +SIGHUP if the process supports it. + +For some use-cases the extra step of calling `initctl reload` creates an +unnecessary overhead, which can be removed at build-time using: + + configure --enable-auto-reload + + Runparts & /etc/rc.local ------------------------ diff --git a/configure.ac b/configure.ac index 5e3d2f72..c51518b4 100644 --- a/configure.ac +++ b/configure.ac @@ -57,6 +57,10 @@ AC_ARG_ENABLE(fallback_shell, AS_HELP_STRING([--enable-fallback-shell], [Start a shell if no TTYs can start]),,[ enable_fallback_shell=no]) +AC_ARG_ENABLE(auto_reload, + AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[ + enable_auto_reload=no]) + AC_ARG_ENABLE(rw-rootfs, AS_HELP_STRING([--enable-rw-rootfs], [Remount / R/W at boot, usually not for embedded]),,[ enable_rw_rootfs=no]) @@ -157,6 +161,9 @@ AS_IF([test "x$enable_emergency_shell" = "xyes"], [ AS_IF([test "x$enable_fallback_shell" = "xyes"], [ AC_DEFINE(FALLBACK_SHELL, 1, [Start /bin/sh on console if no TTYs.])]) +AS_IF([test "x$enable_auto_reload" = "xyes"], [ + AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])]) + AS_IF([test "x$enable_rw_rootfs" = "xyes"], [ AC_DEFINE(REMOUNT_ROOTFS, 1, [Remount / as rw at boot])]) diff --git a/src/conf.c b/src/conf.c index 8d027ff5..52d2b563 100644 --- a/src/conf.c +++ b/src/conf.c @@ -785,8 +785,10 @@ static void conf_cb(uev_t *w, void *arg, int events) } } +#ifdef ENABLE_AUTO_RELOAD if (conf_any_change()) service_reload_dynamic(); +#endif } static int add_watcher(uev_ctx_t *ctx, uev_t *w, char *path, uint32_t opt)