Your message dated Fri, 27 Sep 2019 23:36:48 +0000
with message-id <[email protected]>
and subject line Bug#933078: fixed in runit 2.1.2-35
has caused the Debian Bug report #933078,
regarding runit: forced-rescan feature
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
933078: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933078
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: runit
Version: 2.1.2-32
Severity: wishlist
Tags: patch
Hi!
As I glanced over discussion of adding runit support into
init-system-helpers (thx, Lorenzo), it seemed that it would simplify
things to have a way to force runsvdir re-scan service directory without
waiting for up to 5 seconds.
I prepared prelimitary patch, that implements this feature. When
runsvdir receives SIGALRM, it rescans service directory and writes
timestamp into `.force-rescan' file.
Here I request review. Is this feature really needed. Is timestamp file
needed? Maybe there are simplier ways to implement it?
Making `runit-init` to forward SIGALRM to `runsvdir' does not seems
hard, if we agree on this design.
Here is code:
From fd2712368863c3661bc04d9507883b72e71e3f70 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <[email protected]>
Date: Mon, 15 Jul 2019 23:51:43 +0000
Subject: [PATCH 1/2] Make runsvdir(8) rescan directory on SIGALARM
Generally runsvdir(8) rescans service directory every 5 seconds. This patch
makes it possbile to force rescan by sending SIGALARM.
This feature is wanted by maintainer scripts of packages that want to perform
some action after service was started. Obliviously, hanging installation
process for 5 seconds is sub-optimal in such situation.
---
runit-2.1.2/src/Makefile | 4 ++--
runit-2.1.2/src/runsvdir.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/runit-2.1.2/src/Makefile b/runit-2.1.2/src/Makefile
index a5f3558..28db6fd 100644
--- a/runit-2.1.2/src/Makefile
+++ b/runit-2.1.2/src/Makefile
@@ -14,8 +14,8 @@ runit-init: load runit-init.o unix.a byte.a
runsv: load runsv.o unix.a byte.a time.a
./load runsv unix.a byte.a time.a
-runsvdir: load runsvdir.o unix.a byte.a time.a
- ./load runsvdir unix.a byte.a time.a
+runsvdir: load runsvdir.o unix.a fmt_ptime.o byte.a time.a byte.a
+ ./load runsvdir unix.a fmt_ptime.o byte.a time.a byte.a
runsvstat: load runsvstat.o unix.a byte.a time.a
./load runsvstat unix.a byte.a time.a
diff --git a/runit-2.1.2/src/runsvdir.c b/runit-2.1.2/src/runsvdir.c
index c45b4ee..7ac7999 100644
--- a/runit-2.1.2/src/runsvdir.c
+++ b/runit-2.1.2/src/runsvdir.c
@@ -15,10 +15,17 @@
#include "iopause.h"
#include "sig.h"
#include "ndelay.h"
+#include "fmt_ptime.h"
#define USAGE " [-P] dir"
#define VERSION "$Id: ecebd0a50510e91639c6a45dda8b0947aa8eb885 $"
+/*
+ * After rescan of {svdir} that was forced by sig_alarm (as opposed to regular
+ * rescan once every 5 seconds) is finished, timestamp is written to this path
+ * (relative to {svdir}).
+ */
+#define FORCED_RESCAN "./.forced-rescan"
#define MAXSERVICES 1000
char *progname;
@@ -40,6 +47,7 @@ iopause_fd io[1];
struct taia stamplog;
int exitsoon =0;
int pgrp =0;
+int siga =0;
void usage () { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
void fatal(char *m1, char *m2) {
@@ -53,6 +61,28 @@ void warn3x(char *m1, char *m2, char *m3) {
}
void s_term() { exitsoon =1; }
void s_hangup() { exitsoon =2; }
+void s_alarm() { siga = 1; }
+
+void report_forced_rescan() {
+ struct taia stamp;
+ char buf[26];
+ int fd;
+
+ taia_now(&stamp);
+ fmt_taia(buf, &stamp);
+ buf[25] =0;
+
+ fd =open_trunc(FORCED_RESCAN);
+ if (fd == -1) {
+ warn3x("failed to open", FORCED_RESCAN, buf);
+ return;
+ }
+
+ if (write(fd, buf, 25) != 25)
+ warn3x("failed to write", FORCED_RESCAN, buf);
+
+ close(fd);
+}
void runsv(int no, char *name) {
int pid;
@@ -70,6 +100,7 @@ void runsv(int no, char *name) {
prog[2] =0;
sig_uncatch(sig_hangup);
sig_uncatch(sig_term);
+ sig_uncatch(sig_alarm);
if (pgrp) setsid();
pathexec_run(*prog, prog, (char * const *)environ);
fatal("unable to start runsv ", name);
@@ -183,6 +214,7 @@ int main(int argc, char **argv) {
sig_catch(sig_term, s_term);
sig_catch(sig_hangup, s_hangup);
+ sig_catch(sig_alarm, s_alarm);
svdir =*argv++;
if (argv && *argv) {
rplog =*argv;
@@ -236,6 +268,10 @@ int main(int argc, char **argv) {
if (now.sec.x <= (4611686018427387914ULL +(uint64)mtime))
sleep(1);
runsvdir();
+ if (siga) {
+ report_forced_rescan();
+ siga =0;
+ }
while (fchdir(curdir) == -1) {
warn("unable to change directory, pausing", 0);
sleep(5);
From d9e37e0f9f303a3d25eb31a5a78d277e176b29c6 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <[email protected]>
Date: Fri, 26 Jul 2019 07:23:35 +0000
Subject: [PATCH 2/2] Add regression test for forced-rescan feature
---
runit-2.1.2/src/Makefile | 1 +
runit-2.1.2/src/t/runtest.sh | 41 +++++++++++++++++++++++++++++++++
runit-2.1.2/src/t/timestamp/run | 3 +++
3 files changed, 45 insertions(+)
create mode 100755 runit-2.1.2/src/t/runtest.sh
create mode 100755 runit-2.1.2/src/t/timestamp/run
diff --git a/runit-2.1.2/src/Makefile b/runit-2.1.2/src/Makefile
index 28db6fd..07cbff7 100644
--- a/runit-2.1.2/src/Makefile
+++ b/runit-2.1.2/src/Makefile
@@ -4,6 +4,7 @@ default: sysdeps $(IT)
check: $(IT)
./check-local $(IT)
+ cd t && runsvdir=../runsvdir ./runtest.sh
runit: load runit.o unix.a byte.a
./load runit unix.a byte.a
diff --git a/runit-2.1.2/src/t/runtest.sh b/runit-2.1.2/src/t/runtest.sh
new file mode 100755
index 0000000..c9fc5b3
--- /dev/null
+++ b/runit-2.1.2/src/t/runtest.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+set -eu
+
+: "${runsvdir:=runsvdir}"
+
+rm -rf timestamp/supervise/ service/
+rm -f ./timestamp.txt
+
+mkdir service
+
+"${runsvdir}" ./service &
+echo "pid = $!"
+# Wait till runsvdir scans directory and concludes it is empty
+sleep 1
+now=$(date +%s)
+echo "now = ${now}"
+ln -sf ../timestamp service/
+kill -ALRM $!
+sleep 0.5
+kill -0 $!
+
+# Wait until runsvdir discovers "service/timestamp" symbolic link
+# and executes "service/timestamp/run" script, which would create
+# "./timestamp" file.
+
+while ! test -f ./timestamp.txt ; do
+ sleep 0.01
+done
+
+new=$(cat timestamp.txt)
+echo "new = ${new}"
+kill -HUP $!
+
+if [[ $((new - now)) -lt 2 ]] ; then
+ echo "fine. forced-rescan seems to work"
+ exit 0
+else
+ echo "bad. forced-rescan took too long"
+ exit 1
+fi
+
diff --git a/runit-2.1.2/src/t/timestamp/run b/runit-2.1.2/src/t/timestamp/run
new file mode 100755
index 0000000..4c13d68
--- /dev/null
+++ b/runit-2.1.2/src/t/timestamp/run
@@ -0,0 +1,3 @@
+#!/bin/sh
+date +%s > ../timestamp.txt
+sv down .
pgpC3mU478vYK.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
Source: runit
Source-Version: 2.1.2-35
We believe that the bug you reported is fixed in the latest version of
runit, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Dmitry Bogatov <[email protected]> (supplier of updated runit package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Format: 1.8
Date: Fri, 27 Sep 2019 23:19:30 +0000
Source: runit
Architecture: source
Version: 2.1.2-35
Distribution: unstable
Urgency: medium
Maintainer: Dmitry Bogatov <[email protected]>
Changed-By: Dmitry Bogatov <[email protected]>
Closes: 933078 939971 941273
Changes:
runit (2.1.2-35) unstable; urgency=medium
.
* Temporary disable forced-rescan test (Closes: #941273)
.
runit (2.1.2-34) unstable; urgency=medium
.
[ Dmitry Bogatov ]
* Add series of patches to implement force-rescan feature (Closes: #933078)
* Fix 1 second delay in forced rescan implementation
.
[ Lorenzo Puliti ]
* update-service: move supervise directories in tmpfs
* invoke-run: add verbose option and export NAME (Closes: #939971)
Checksums-Sha1:
ba3bd305748048a77f4115840e503485b10f7b53 2221 runit_2.1.2-35.dsc
4045d51a984b694c727be7787b048feba3c16378 40416 runit_2.1.2-35.debian.tar.xz
e4b2de488679b0aeab7b788424139cb436165a87 6015 runit_2.1.2-35_source.buildinfo
Checksums-Sha256:
853f93541f88ce7ea070379a0ada19b11fd9f18ff0fc50550e891925d0584359 2221
runit_2.1.2-35.dsc
043bb18dec013c82ba499f8d2189b8e6eb0bf8540187a2b590d3bed8ba3775b9 40416
runit_2.1.2-35.debian.tar.xz
a5f7f6192627ffd73be88428bef418391cde64cacb50f7f7ad40c26d355c0f4f 6015
runit_2.1.2-35_source.buildinfo
Files:
1fbe2c59b520ad92a75e47dbfb9b56bc 2221 admin optional runit_2.1.2-35.dsc
e3dd03c290826e03e93ed14a7f1c100b 40416 admin optional
runit_2.1.2-35.debian.tar.xz
81c222aab5261d4ff0ac1ec0419f3a10 6015 admin optional
runit_2.1.2-35_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iQJHBAEBCgAxFiEEhnHVzDbtdH7ktKj4SBLY3qgmEeYFAl2OmSgTHGthY3Rpb25A
ZGViaWFuLm9yZwAKCRBIEtjeqCYR5u0UD/97bnqQ/zcuv3I5DlMqNHLY3gUqKXPq
E4kuTLZhgBcFenr43yRQOtTJu5dFX1PxU9frGMKekDvvyDiEVoBEB8Tz5nkvKGA4
6vUCHEl8JxwIZ1wOw2VOazofc9GAMB9mDD74NN+bjjlcuDPdsiyrCUiqdoVrDgKI
+LVA5zfOsiKgsGyFbEWY3ACA4g8TR9+GkXSz0qHxw7V3dAHG0hTTlDhXIHN9MjQl
5+GdFs/8gTDy7OPNih/WcYhVLTqNmSIZZntHN9DGhqWhpC/DuS/1vQygZv5EUcUQ
nRQAW+N9PDBZqI2rePJgeUvXnMn8G/lsPp1Wqw2UOa7xk202t7+5XgUuvstb7hxp
d1qHkjQCnIJG0puzdG9x2d433TRQtypmQwAWcM5T6YuTAti3KXfAZqJ7Rxpi0BcF
b0ORz5LT+wkmRIRV8acgg7Nu0oWSkMYbnDknOrNbintOd8mzrUkO0MMSH9JYY4RY
6InX/ZbdRWOeXncJ88titEKHqXh2ukzjAANFIF2nUWZStlXUl8OaiAo0jhW9mDEe
KlvRxOouB1eTzlcQQhHERzd4vHOqlqZ5AfoPZyx21uxS7TIiQkAnnQpHIW62LCz1
koB66kA8Fp4Ss38GB5hNm4dl/x6h9z7QzCva5dvHBGz1HqtKm6xjRWEkqSHbWJu/
PKs86YHl2PYS9Q==
=bONw
-----END PGP SIGNATURE-----
--- End Message ---