diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-01-11 11:36:38 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-01-11 11:36:38 +0000 |
commit | a37ea0818a0889fbf36a4fbe918929b53fb0f7c6 (patch) | |
tree | 8b5721e9cea4bcdc016cd5a36c4f0c630ea94074 | |
parent | 7b9931e6403db6aeabb0ccc26e126dcf74cf3c03 (diff) | |
download | s6-a37ea0818a0889fbf36a4fbe918929b53fb0f7c6.tar.gz s6-a37ea0818a0889fbf36a4fbe918929b53fb0f7c6.tar.xz s6-a37ea0818a0889fbf36a4fbe918929b53fb0f7c6.zip |
More bugfixes
And doc fixes Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | doc/instances.html | 4 | ||||
-rw-r--r-- | doc/s6-instance-create.html | 2 | ||||
-rw-r--r-- | doc/s6-instance-maker.html | 2 | ||||
-rw-r--r-- | src/supervision/s6-supervise.c | 89 | ||||
-rw-r--r-- | src/supervision/s6-svc.c | 30 |
5 files changed, 60 insertions, 67 deletions
diff --git a/doc/instances.html b/doc/instances.html index 8f49923..53b42e4 100644 --- a/doc/instances.html +++ b/doc/instances.html @@ -19,7 +19,7 @@ <h1> Dynamic instantiation under s6 </h1> <p> - A <em>instanced service</em> is a parameterized service that you want to + An <em>instanced service</em> is a parameterized service that you want to run several copies of, with only the parameter changing. Each copy of the service is called an <em>instance</em>. </p> @@ -86,7 +86,7 @@ here for informational purposes. <ul> <li> The service directory created by <a href="s6-instance-maker.html">s6-instance-maker</a> -has two specifics subdirectories in it: <tt>instance</tt> and <tt>instances</tt>. They +has two specific subdirectories in it: <tt>instance</tt> and <tt>instances</tt>. They are initially empty, except that the template service directory is stored in <tt>instances/.template</tt>. </li> <li> When the service is active, there is an <a href="s6-svscan.html">s6-svscan</a> diff --git a/doc/s6-instance-create.html b/doc/s6-instance-create.html index 1aa0d4c..ea0b633 100644 --- a/doc/s6-instance-create.html +++ b/doc/s6-instance-create.html @@ -63,7 +63,7 @@ been given, the supervisor auto-starts the instance as soon as it runs. </li> <li> <tt>-D</tt> : down, and stay down. The instance supervisor will be started, but the instance itself will remain down. A <tt>down</tt> file will be created for the instance. By default, if neither the <tt>-d</tt> nor <tt>-D</tt> options have -been given, the supervisor auto-starts the instancece as soon as it runs. </li> +been given, the supervisor auto-starts the instance as soon as it runs. </li> <li> <tt>-P</tt> : public. Everyone will be able to subscribe to the instance supervisor's notification. By default, only processes running with the same gid as the instanced service can subscribe to it. </li> diff --git a/doc/s6-instance-maker.html b/doc/s6-instance-maker.html index ac86671..906d041 100644 --- a/doc/s6-instance-maker.html +++ b/doc/s6-instance-maker.html @@ -98,7 +98,7 @@ When the <tt>-r</tt> option is not given at all, <em>dir</em> is a regular servi directory for direct inclusion (or linking) in a host <a href="scandir.html">scan directory</a>, and if the <tt>-L</tt> option is given then the logger for the instance supervisor and all its instances is declared in -<em>dir</em><tt>/log</tt>). </li> <br> +<em>dir</em><tt>/log</tt>. </li> <br> <li> <tt>-u</tt> <em>user</em> : run the instance supervisor, and all of the instances, as user <em>user</em>. This option should only be used when the diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index 7036a6d..fa96a02 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -40,7 +40,7 @@ enum trans_e { V_TIMEOUT, V_CHLD, V_TERM, V_HUP, V_QUIT, V_INT, V_a, V_b, V_q, V_h, V_k, V_t, V_i, V_1, V_2, V_p, V_c, V_y, V_r, - V_o, V_d, V_u, V_x, V_O + V_o, V_d, V_u, V_D, V_U, V_x, V_O } ; typedef enum state_e state_t, *state_t_ref ; @@ -165,6 +165,20 @@ static void closethem (void) strerr_warnwu2sys("open /dev/null for ", "writing") ; } +static void adddown (void) +{ + if (!openwritenclose_unsafe("down", "", 0)) + strerr_warnwu2sys("create ", "./down file") ; +} + +static void deldown (void) +{ + int e = errno ; + if (unlink("down") == -1 && errno != ENOENT) + strerr_warnwu2sys("unlink ", "./down file") ; + errno = e ; +} + static void killa (void) { kill(status.pid, SIGALRM) ; @@ -390,35 +404,46 @@ static void trystart (void) if (lfd >= 0) fd_close(lfd) ; } -static void downtimeout (void) +static void wantdown (void) { - if (status.flagwantup) trystart() ; - else settimeout_infinite() ; + status.flagwantup = 0 ; + announce() ; } -static void down_O (void) +static void wantup (void) { - status.flagwantup = 0 ; + status.flagwantup = 1 ; announce() ; } +static void downtimeout (void) +{ + if (status.flagwantup) trystart() ; + else settimeout_infinite() ; +} + static void down_o (void) { - down_O() ; + wantdown() ; trystart() ; } static void down_u (void) { - status.flagwantup = 1 ; - announce() ; + wantup() ; trystart() ; } -static void down_d (void) +static void down_D (void) { - status.flagwantup = 0 ; - announce() ; + adddown() ; + wantdown() ; +} + +static void down_U (void) +{ + deldown() ; + down_u() ; } static int uplastup_z (void) @@ -512,12 +537,6 @@ static void uptimeout (void) } } -static void up_o (void) -{ - status.flagwantup = 0 ; - announce() ; -} - static void up_d (void) { tain tto ; @@ -534,10 +553,16 @@ static void up_d (void) else settimeout_infinite() ; } -static void up_u (void) +static void up_D (void) { - status.flagwantup = 1 ; - announce() ; + adddown() ; + up_d() ; +} + +static void up_U (void) +{ + deldown() ; + wantup() ; } static void up_x (void) @@ -570,12 +595,6 @@ static void finish_z (void) else set_down_and_ready("D", 1) ; } -static void finish_u (void) -{ - status.flagwantup = 1 ; - announce() ; -} - static void finish_x (void) { state = LASTFINISH ; @@ -588,23 +607,23 @@ static void lastfinish_z (void) bail() ; } -static action_t_ref const actions[5][24] = +static action_t_ref const actions[5][26] = { { &downtimeout, &nop, &bail, &bail, &bail, &bail, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, - &down_o, &down_d, &down_u, &bail, &down_O }, + &down_o, &wantdown, &down_u, &down_D, &down_U, &bail, &wantdown }, { &uptimeout, &up_z, &up_term, &up_x, &bail, &sigint, &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, - &up_o, &up_d, &up_u, &up_x, &up_o }, + &wantdown, &up_d, &wantup, &up_D, &up_U, &up_x, &wantdown }, { &finishtimeout, &finish_z, &finish_x, &finish_x, &bail, &sigint, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, - &up_o, &down_d, &finish_u, &finish_x, &up_o }, + &wantdown, &wantdown, &wantup, &down_D, &up_U, &finish_x, &wantdown }, { &uptimeout, &lastup_z, &up_d, &closethem, &bail, &sigint, &killa, &killb, &killq, &killh, &killk, &killt, &killi, &kill1, &kill2, &killp, &killc, &killy, &killr, - &up_o, &up_d, &nop, &closethem, &up_o }, + &wantdown, &up_d, &wantup, &up_D, &up_U, &closethem, &wantdown }, { &finishtimeout, &lastfinish_z, &nop, &closethem, &bail, &sigint, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, &nop, - &nop, &nop, &nop, &closethem, &nop } + &wantdown, &wantdown, &wantup, &down_D, &up_U, &closethem, &wantdown } } ; @@ -687,8 +706,8 @@ static inline void handle_control (int fd) else if (!r) break ; else { - size_t pos = byte_chr("abqhkti12pcyroduxO", 18, c) ; - if (pos < 18) (*actions[state][V_a + pos])() ; + size_t pos = byte_chr("abqhkti12pcyroduDUxO", 20, c) ; + if (pos < 20) (*actions[state][V_a + pos])() ; } } } diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c index 8c75abb..4485248 100644 --- a/src/supervision/s6-svc.c +++ b/src/supervision/s6-svc.c @@ -21,7 +21,6 @@ int main (int argc, char const *const *argv) { size_t len ; - int downfile = -1 ; unsigned int datalen = 1 ; unsigned int timeout = 0 ; char data[DATASIZE+1] = "-" ; @@ -51,6 +50,8 @@ int main (int argc, char const *const *argv) case 'o' : case 'd' : case 'u' : + case 'D' : + case 'U' : case 'x' : case 'O' : { @@ -58,20 +59,6 @@ int main (int argc, char const *const *argv) data[datalen++] = opt ; break ; } - case 'D' : - { - if (datalen >= DATASIZE) strerr_dief1x(100, "too many commands") ; - data[datalen++] = 'd' ; - downfile = 1 ; - break ; - } - case 'U' : - { - if (datalen >= DATASIZE) strerr_dief1x(100, "too many commands") ; - data[datalen++] = 'u' ; - downfile = 0 ; - break ; - } case 'T' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ; case 'w' : { @@ -102,19 +89,6 @@ int main (int argc, char const *const *argv) } } - if (downfile >= 0) - { - char fn[len + 6] ; - memcpy(fn, argv[0], len) ; - memcpy(fn + len, "/down", 6) ; - if (downfile) - { - if (!openwritenclose_unsafe(fn, "", 0)) - strerr_diefu2sys(111, "touch ", fn) ; - } - else unlink_void(fn) ; - } - if (updown[1]) { char const *newargv[11] ; |