diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-06-18 06:24:01 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-06-18 06:24:01 +0000 |
| commit | 135468b32b12e2f2974b72c61e9d8390e562741e (patch) | |
| tree | f29d727a92b502112b0ee7daed24702a12714967 | |
| parent | 6ec8fe53c5c178fca3fde6ec63257e65f53dc58a (diff) | |
| download | s6-frontend-135468b32b12e2f2974b72c61e9d8390e562741e.tar.gz | |
Add s6 live reload
| -rw-r--r-- | doc/s6_live.html | 36 | ||||
| -rw-r--r-- | package/deps.mak | 3 | ||||
| -rw-r--r-- | src/s6-frontend/deps-exe/s6-frontend | 1 | ||||
| -rw-r--r-- | src/s6-frontend/live.c | 1 | ||||
| -rw-r--r-- | src/s6-frontend/live_reload.c | 73 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend-internal.h | 1 |
6 files changed, 114 insertions, 1 deletions
diff --git a/doc/s6_live.html b/doc/s6_live.html index d770f80..0bb302d 100644 --- a/doc/s6_live.html +++ b/doc/s6_live.html @@ -172,6 +172,42 @@ transitions. By default, <em>timeout</em> is 0, meaning infinite: the command can wait forever. </dd> </dl> +<h3 id="reload"> reload </h3> + +<h4> Interface </h4> + +<pre> + s6 live reload [ -n ] [ -t <em>timeout</em> ] <em>servicenames...</em> +</pre> + +<ul> + <li> <tt>s6 live reload <em>servicenames...</em></tt> reloads the services +defined in the current live database and listed by name in <em>servicenames</em>. </li> + <li> <em>Reloading</em> means: + <ul> + <li> if the service is a longrun: sending a SIGHUP, or the signal defined in the +service directory's <tt>down-signal</tt> file, to the process. </li> + <li> if the service is a oneshot: executing the <tt>reload</tt> script defined +for it. </li> + <li> <tt>s6 live reload</tt> only applies to the listed services. It does not +touch dependencies. It does not change service states: if a service is down, +<tt>reload</tt> has no effect, and if a service is up, it is still up after +reloading. </li> +</ul> + +<h4> Options </h4> + +<dl> +<dt> <tt>-n</tt>, <tt>--dry-run</tt> </dt> +<dd> Only print what would be done; do not actually reload services. </dd> + +<dt> <tt>-t <em>timeout</em></tt>, <tt>--timeout=<em>timeout</em></tt> </dt> +<dd> If a reload script still hasn't completed after <em>timeout</em> +milliseconds, stop waiting for it and consider the reload a failure. +By default, <em>timeout</em> is 0, meaning infinite: the +command can wait forever. </dd> +</dl> + <h3 id="start-everything"> start-everything </h3> <h4> Interface </h4> diff --git a/package/deps.mak b/package/deps.mak index 856a4ff..923fcfc 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -11,6 +11,7 @@ src/libs6f/s6f_report_state_change.o src/libs6f/s6f_report_state_change.lo: src/ src/libs6f/s6f_user_get_confdirs.o src/libs6f/s6f_user_get_confdirs.lo: src/libs6f/s6f_user_get_confdirs.c src/include-local/s6f.h src/s6-frontend/live.o src/s6-frontend/live.lo: src/s6-frontend/live.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/live_install.o src/s6-frontend/live_install.lo: src/s6-frontend/live_install.c src/s6-frontend/s6-frontend-internal.h +src/s6-frontend/live_reload.o src/s6-frontend/live_reload.lo: src/s6-frontend/live_reload.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h src/s6-frontend/live_start_everything.o src/s6-frontend/live_start_everything.lo: src/s6-frontend/live_start_everything.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h src/s6-frontend/live_startstop.o src/s6-frontend/live_startstop.lo: src/s6-frontend/live_startstop.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/live_status.o src/s6-frontend/live_status.lo: src/s6-frontend/live_status.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h @@ -54,5 +55,5 @@ endif s6: EXTRA_LIBS := s6: src/s6-frontend/s6.o -lskarnet s6-frontend: EXTRA_LIBS := ${MAYBEPTHREAD_LIB} -s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/live.o src/s6-frontend/live_help.o src/s6-frontend/live_install.o src/s6-frontend/live_startstop.o src/s6-frontend/live_status.o src/s6-frontend/live_start_everything.o src/s6-frontend/live_stop_everything.o src/s6-frontend/main_help.o src/s6-frontend/process.o src/s6-frontend/process_help.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/repository.o src/s6-frontend/repository_check.o src/s6-frontend/repository_help.o src/s6-frontend/repository_init.o src/s6-frontend/repository_list.o src/s6-frontend/repository_sync.o src/s6-frontend/set.o src/s6-frontend/set_change.o src/s6-frontend/set_check.o src/s6-frontend/set_commit.o src/s6-frontend/set_copy.o src/s6-frontend/set_delete.o src/s6-frontend/set_help.o src/s6-frontend/set_list.o src/s6-frontend/set_status.o src/s6-frontend/system.o src/s6-frontend/system_boot.o src/s6-frontend/system_help.o src/s6-frontend/system_hpr.o src/s6-frontend/version.o src/s6-frontend/version_export.o src/s6-frontend/version_help.o src/s6-frontend/version_show.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet +s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/live.o src/s6-frontend/live_help.o src/s6-frontend/live_install.o src/s6-frontend/live_reload.o src/s6-frontend/live_startstop.o src/s6-frontend/live_status.o src/s6-frontend/live_start_everything.o src/s6-frontend/live_stop_everything.o src/s6-frontend/main_help.o src/s6-frontend/process.o src/s6-frontend/process_help.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/repository.o src/s6-frontend/repository_check.o src/s6-frontend/repository_help.o src/s6-frontend/repository_init.o src/s6-frontend/repository_list.o src/s6-frontend/repository_sync.o src/s6-frontend/set.o src/s6-frontend/set_change.o src/s6-frontend/set_check.o src/s6-frontend/set_commit.o src/s6-frontend/set_copy.o src/s6-frontend/set_delete.o src/s6-frontend/set_help.o src/s6-frontend/set_list.o src/s6-frontend/set_status.o src/s6-frontend/system.o src/s6-frontend/system_boot.o src/s6-frontend/system_help.o src/s6-frontend/system_hpr.o src/s6-frontend/version.o src/s6-frontend/version_export.o src/s6-frontend/version_help.o src/s6-frontend/version_show.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet INTERNAL_LIBS := libs6f.a.xyzzy diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend index 8903175..b6d45c0 100644 --- a/src/s6-frontend/deps-exe/s6-frontend +++ b/src/s6-frontend/deps-exe/s6-frontend @@ -1,6 +1,7 @@ live.o live_help.o live_install.o +live_reload.o live_startstop.o live_status.o live_start_everything.o diff --git a/src/s6-frontend/live.c b/src/s6-frontend/live.c index c1942b1..467dd40 100644 --- a/src/s6-frontend/live.c +++ b/src/s6-frontend/live.c @@ -17,6 +17,7 @@ void live (char const *const *argv) { { .s = "help", .f = &live_help }, { .s = "install", .f = &live_install }, + { .s = "reload", .f = &live_reload }, { .s = "reset", .f = &live_reset }, { .s = "restart", .f = &live_restart }, { .s = "start", .f = &live_start }, diff --git a/src/s6-frontend/live_reload.c b/src/s6-frontend/live_reload.c new file mode 100644 index 0000000..1750440 --- /dev/null +++ b/src/s6-frontend/live_reload.c @@ -0,0 +1,73 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/strerr.h> +#include <skalibs/gol.h> +#include <skalibs/env.h> + +#include <s6-frontend/config.h> +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_DRYRUN = 0x01, +} ; + +enum gola_e +{ + GOLA_TIMEOUT, + GOLA_N +} ; + +void live_reload (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN }, + } ; + static gol_arg const rgola[] = + { + { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT }, + } ; + uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { 0 } ; + unsigned int timeout = 0 ; + unsigned int m = 0 ; + unsigned int argc ; + char fmtv[UINT_FMT] ; + char fmtt[UINT_FMT] ; + + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + if (!*argv) strerr_die(100, "usage: ", "s6 live reload [ -n ] [ -t timeout ] services...") ; + if (wgola[GOLA_TIMEOUT]) + { + if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout)) + strerr_dief1x(100, "timeout must be an integer (milliseconds)") ; + } + argc = env_len(argv) ; + + char const *newargv[11 + argc] ; + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc" ; + if (g->verbosity != 1) + { + fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ; + newargv[m++] = "-v" ; + newargv[m++] = fmtv ; + } + if (timeout) + { + fmtt[uint_fmt(fmtt, timeout)] = 0 ; + newargv[m++] = "-t" ; + newargv[m++] = fmtt ; + } + if (wgolb & GOLB_DRYRUN) newargv[m++] = "-n1" ; + newargv[m++] = "-l" ; + newargv[m++] = g->dirs.live ; + newargv[m++] = "-b" ; + newargv[m++] = "--" ; + newargv[m++] = "reload" ; + for (unsigned int i = 0 ; i < argc ; i++) newargv[m++] = argv[i] ; + newargv[m++] = 0 ; + main_exec(newargv) ; +} diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h index 2bc83b0..dad191b 100644 --- a/src/s6-frontend/s6-frontend-internal.h +++ b/src/s6-frontend/s6-frontend-internal.h @@ -26,6 +26,7 @@ extern void exec_live_start_everything (unsigned int, char const *, unsigned int extern void live (char const *const *) gccattr_noreturn ; extern void live_help (char const *const *) gccattr_noreturn ; +extern void live_reload (char const *const *) gccattr_noreturn ; extern void live_restart (char const *const *) gccattr_noreturn ; extern void live_start (char const *const *) gccattr_noreturn ; extern void live_status (char const *const *) gccattr_noreturn ; |
