mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
.conf: don't rely on mtime to determine if service needs reloading
Until now Finit has used mtime to determine if a file has been changed, or simply touched to request reload, when `initctl reload` is called. Using mtime for this purpose is a monumentally bad idea since time can be changed at any point: a user may adjust the time, NTP continously tunes the clock, and time stamps are stored as the walltime. So if we compare timestamps against the last time we (booted or) did reload, we would miss .conf file changes. This patch replaces the mtime mistake with an inotify watcher for the following files: /etc/finit.d/*.conf, /etc/finit.d/available/*.conf, and /etc/finit.conf. All file changes between (bootstraps and) calls to `initctl reload` are tracked, like the mtime backend it replaces. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
bb3d9c8670
commit
b439ac670d
10 files changed
+261
-90
No files matched your search
+5
-11
@@ -447,19 +447,15 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse /etc/finit.conf and all *.conf in /etc/finit.d/ to
|
||||
* figure out how to bootstrap the system.
|
||||
* Initialize .conf system and load static /etc/finit.conf
|
||||
*/
|
||||
conf_parse_config();
|
||||
conf_init();
|
||||
|
||||
/*
|
||||
* Start built-in watchdog as soon as possible, if enabled
|
||||
*/
|
||||
wdogpid = watchdog(argv[0]);
|
||||
|
||||
/* Set hostname as soon as possible, for syslog et al. */
|
||||
set_hostname(&hostname);
|
||||
|
||||
/*
|
||||
* Mount filesystems
|
||||
*/
|
||||
@@ -488,12 +484,10 @@ int main(int argc, char* argv[])
|
||||
sig_setup(&loop);
|
||||
|
||||
/*
|
||||
* Reload all *.conf in /etc/finit.d, the mount command (above)
|
||||
* may have brought in new files (overlayfs).
|
||||
*
|
||||
* XXX: Can we detect remounted /etc to trigger this instead?
|
||||
* Set up inotify watcher for /etc/finit.d and read all .conf
|
||||
* files to figure out how to bootstrap the system.
|
||||
*/
|
||||
conf_reload_dynamic();
|
||||
conf_monitor(&loop);
|
||||
|
||||
_d("Base FS up, calling hooks ...");
|
||||
plugin_run_hooks(HOOK_BASEFS_UP);
|
||||
|
||||
Reference in new issue
Block a user