mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
Add support for adding/removing services from /etc/finit.d at runtime.
This patch adds support for adding and removing services from Finit at runtime. Configuration file stanzas for service, run and task may now be written to files in /etc/finit.d/*.conf, using the exact same syntax as before in /etc/finit.conf. When a file is added, removed or modified the user may simply SIGHUP Finit (PID 1) to activate the changes. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
24051ab2fb
commit
687f52b0b5
10 files changed
+454
-233
No files matched your search
@@ -48,7 +48,7 @@
|
||||
#include "sig.h"
|
||||
|
||||
static int stopped = 0;
|
||||
static uev_t sigint_watcher, sigpwr_watcher;
|
||||
static uev_t sighup_watcher, sigint_watcher, sigpwr_watcher;
|
||||
static uev_t sigchld_watcher, sigsegv_watcher;
|
||||
static uev_t sigstop_watcher, sigtstp_watcher, sigcont_watcher;
|
||||
|
||||
@@ -87,6 +87,24 @@ void do_shutdown(int sig)
|
||||
reboot(RB_POWER_OFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reload .conf files in /etc/finit.d/
|
||||
*/
|
||||
static void sighup_cb(uev_ctx_t *UNUSED(ctx), uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
|
||||
{
|
||||
/* Mark and sweep */
|
||||
svc_mark_dynamic();
|
||||
|
||||
/* Reload all *.conf in /etc/finit.d/ */
|
||||
parse_finit_d(rcsd);
|
||||
|
||||
/* Reload dirty services */
|
||||
svc_reload_dynamic();
|
||||
|
||||
/* Cleanup stale services */
|
||||
svc_cleanup();
|
||||
}
|
||||
|
||||
/*
|
||||
* Shut down on INT PWR
|
||||
*/
|
||||
@@ -207,8 +225,8 @@ void sig_setup(uev_ctx_t *ctx)
|
||||
/* Some C APIs may need SIGALRM for implementing timers. */
|
||||
IGNSIG(sa, SIGALRM, 0);
|
||||
|
||||
/* We don't have any /etc/inittab yet, reread finit.conf? */
|
||||
IGNSIG(sa, SIGHUP, 0);
|
||||
/* /etc/inittab not supported yet, instead /etc/finit.d/ is scanned for *.conf */
|
||||
uev_signal_init(ctx, &sighup_watcher, sighup_cb, NULL, SIGHUP);
|
||||
|
||||
/* After initial bootstrap of Finit we call the service monitor to reap children */
|
||||
uev_signal_init(ctx, &sigchld_watcher, sigchld_cb, NULL, SIGCHLD);
|
||||
|
||||
Reference in new issue
Block a user