summaryrefslogtreecommitdiff
path: root/src/supervision
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-08-30 19:11:44 +0000
committerLaurent Bercot <ska@appnovation.com>2021-08-30 19:11:44 +0000
commit691c69e626e4ceb85567a5288348bd04378fd410 (patch)
tree9ae1c3f2c2984aafa2b9caf7987fe0011fcf6828 /src/supervision
parent1719a60278cf36558b568349c0c9f9b5eb91c999 (diff)
downloads6-691c69e626e4ceb85567a5288348bd04378fd410.tar.xz
s6-svlink, s6-svunlink, .h changes
Renamed from s6-svdir-(un)link. Doc added. Full functionality added. Still need to be tested. Unrelated: .h names simplified. Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/deps-exe/s6-svdir-unlink2
-rw-r--r--src/supervision/deps-exe/s6-svlink (renamed from src/supervision/deps-exe/s6-svdir-link)0
-rw-r--r--src/supervision/deps-exe/s6-svunlink5
-rw-r--r--src/supervision/s6-permafailon.c2
-rw-r--r--src/supervision/s6-supervise.c3
-rw-r--r--src/supervision/s6-svc.c2
-rw-r--r--src/supervision/s6-svdir-unlink.c38
-rw-r--r--src/supervision/s6-svdt-clear.c2
-rw-r--r--src/supervision/s6-svdt.c2
-rw-r--r--src/supervision/s6-svlink.c (renamed from src/supervision/s6-svdir-link.c)34
-rw-r--r--src/supervision/s6-svok.c2
-rw-r--r--src/supervision/s6-svperms.c2
-rw-r--r--src/supervision/s6-svscan.c2
-rw-r--r--src/supervision/s6-svscanctl.c2
-rw-r--r--src/supervision/s6-svstat.c6
-rw-r--r--src/supervision/s6-svunlink.c49
-rw-r--r--src/supervision/s6_svlisten_loop.c2
17 files changed, 89 insertions, 66 deletions
diff --git a/src/supervision/deps-exe/s6-svdir-unlink b/src/supervision/deps-exe/s6-svdir-unlink
deleted file mode 100644
index 08815d9..0000000
--- a/src/supervision/deps-exe/s6-svdir-unlink
+++ /dev/null
@@ -1,2 +0,0 @@
-${LIBS6}
--lskarnet
diff --git a/src/supervision/deps-exe/s6-svdir-link b/src/supervision/deps-exe/s6-svlink
index 16eaae2..16eaae2 100644
--- a/src/supervision/deps-exe/s6-svdir-link
+++ b/src/supervision/deps-exe/s6-svlink
diff --git a/src/supervision/deps-exe/s6-svunlink b/src/supervision/deps-exe/s6-svunlink
new file mode 100644
index 0000000..16eaae2
--- /dev/null
+++ b/src/supervision/deps-exe/s6-svunlink
@@ -0,0 +1,5 @@
+${LIBS6}
+-lskarnet
+${SOCKET_LIB}
+${SYSCLOCK_LIB}
+${SPAWN_LIB}
diff --git a/src/supervision/s6-permafailon.c b/src/supervision/s6-permafailon.c
index b5bb469..d34d09b 100644
--- a/src/supervision/s6-permafailon.c
+++ b/src/supervision/s6-permafailon.c
@@ -11,7 +11,7 @@
#include <skalibs/tai.h>
#include <skalibs/exec.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-permafailon seconds deathcount statuslist prog..."
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index 84290ab..cc6779a 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -25,7 +25,7 @@
#include <skalibs/skamisc.h>
#include <s6/ftrigw.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-supervise dir"
#define CTL S6_SUPERVISE_CTLDIR "/control"
@@ -416,7 +416,6 @@ static int uplastup_z (void)
status.wstat = (int)status.pid ;
status.flagpaused = 0 ;
status.flagready = 0 ;
- status.flagthrottled = 0 ;
flagdying = 0 ;
tain_wallclock_read(&status.stamp) ;
if (notifyfd >= 0)
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index 30a6fb3..5467ea2 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -10,7 +10,7 @@
#include <skalibs/exec.h>
#include <s6/config.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyroduxOX ] servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svdir-unlink.c b/src/supervision/s6-svdir-unlink.c
deleted file mode 100644
index 0e8699e..0000000
--- a/src/supervision/s6-svdir-unlink.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ISC license. */
-
-#include <stdint.h>
-
-#include <skalibs/sgetopt.h>
-#include <skalibs/strerr2.h>
-
-#include <s6/s6-supervise.h>
-
-#define USAGE "s6-svdir-unlink [ -d ] [ -x ] scandir servicename"
-#define dieusage() strerr_dieusage(100, USAGE)
-
-int main (int argc, char const *const *argv)
-{
- uint32_t options = 0 ;
- PROG = "s6-svdir-link" ;
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "dx", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'd' : options = 3 ; break ;
- case 'x' : options = 1 ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
- if (argc < 2) dieusage() ;
-
- if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/')
- strerr_dief1x(100, "invalid service name") ;
- s6_supervise_unlink(argv[0], argv[1], options) ;
- return 0 ;
-}
diff --git a/src/supervision/s6-svdt-clear.c b/src/supervision/s6-svdt-clear.c
index 791dd61..6b36718 100644
--- a/src/supervision/s6-svdt-clear.c
+++ b/src/supervision/s6-svdt-clear.c
@@ -1,7 +1,7 @@
/* ISC license. */
#include <skalibs/strerr2.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svdt-clear servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svdt.c b/src/supervision/s6-svdt.c
index ab0dfc8..3df356a 100644
--- a/src/supervision/s6-svdt.c
+++ b/src/supervision/s6-svdt.c
@@ -6,7 +6,7 @@
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
#include <skalibs/sig.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svdt [ -S | -s ] [ -n maxentries ] servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svdir-link.c b/src/supervision/s6-svlink.c
index 8329197..159f817 100644
--- a/src/supervision/s6-svdir-link.c
+++ b/src/supervision/s6-svlink.c
@@ -4,16 +4,19 @@
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
+#include <libgen.h>
+#include <skalibs/posixplz.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/tai.h>
#include <skalibs/strerr2.h>
+#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
-#define USAGE "s6-svdir-link [ -d ] [ -f ] [ -P | -p ] [ -t timeout ] scandir name servicedir"
+#define USAGE "s6-svlink [ -d | -D ] [ -f ] [ -P ] [ -t timeout ] scandir servicedir [ name ]"
#define dieusage() strerr_dieusage(100, USAGE)
static inline void checkscandir (char const *s)
@@ -67,20 +70,21 @@ int main (int argc, char const *const *argv)
{
tain tto = TAIN_INFINITE_RELATIVE ;
uint32_t options = 0 ;
- PROG = "s6-svdir-link" ;
+ char const *name ;
+ PROG = "s6-svlink" ;
{
unsigned int t = 0 ;
subgetopt l = SUBGETOPT_ZERO ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "dfPpt:", &l) ;
+ int opt = subgetopt_r(argc, argv, "dDfPt:", &l) ;
if (opt == -1) break ;
switch (opt)
{
- case 'd' : options |= 4 ; break ;
+ case 'd' : options |= 12 ; break ;
+ case 'D' : options |= 4 ; options &= ~8U ; break ;
case 'f' : options |= 1 ; break ;
case 'P' : options |= 2 ; break ;
- case 'p' : options &= ~2U ; break ;
case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
default : dieusage() ;
}
@@ -88,18 +92,26 @@ int main (int argc, char const *const *argv)
argc -= l.ind ; argv += l.ind ;
if (t) tain_from_millisecs(&tto, t) ;
}
- if (argc < 3) dieusage() ;
+ if (argc < 2) dieusage() ;
+ if (argv[2]) name = argv[2] ;
+ else
+ {
+ stralloc sa = STRALLOC_ZERO ;
+ if (!stralloc_cats(&sa, argv[1]) || !stralloc_0(&sa))
+ strerr_diefu1sys(111, "stralloc_cats") ;
+ name = basename(sa.s) ;
+ }
if (!argv[0][0]) strerr_dief1x(100, "invalid scandir") ;
- if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/')
+ if (!argv[1][0]) strerr_dief1x(100, "invalid servicedir") ;
+ if (!name[0] || name[0] == '.' || name[0] == '/')
strerr_dief1x(100, "invalid name") ;
- if (!argv[2][0]) strerr_dief1x(100, "invalid servicedir") ;
checkscandir(argv[0]) ;
tain_now_set_stopwatch_g() ;
tain_add_g(&tto, &tto) ;
- if (s6_supervise_link_names_g(argv[0], argv + 2, argv + 1, 1, options, &tto) == -1)
- strerr_diefu6sys(111, "link servicedir ", argv[2], " into scandir ", argv[0], " with name ", argv[1]) ;
+ if (s6_supervise_link_names_g(argv[0], argv + 1, &name, 1, options, &tto) == -1)
+ strerr_diefu6sys(errno == ETIMEDOUT ? 99 : 111, "link servicedir ", argv[1], " into scandir ", argv[0], " with name ", name) ;
return 0 ;
}
diff --git a/src/supervision/s6-svok.c b/src/supervision/s6-svok.c
index 176d8a8..c6c6bd4 100644
--- a/src/supervision/s6-svok.c
+++ b/src/supervision/s6-svok.c
@@ -1,7 +1,7 @@
/* ISC license. */
#include <skalibs/strerr2.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svok servicedir"
diff --git a/src/supervision/s6-svperms.c b/src/supervision/s6-svperms.c
index fb35715..4b8de05 100644
--- a/src/supervision/s6-svperms.c
+++ b/src/supervision/s6-svperms.c
@@ -12,7 +12,7 @@
#include <skalibs/buffer.h>
#include <skalibs/strerr2.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svperms [ -v ] [ -u | -g group | -G group | -o | -O group ] [ -e | -E group ] servicedir..."
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
index da2dc30..ee0b013 100644
--- a/src/supervision/s6-svscan.c
+++ b/src/supervision/s6-svscan.c
@@ -22,7 +22,7 @@
#include <skalibs/exec.h>
#include <s6/config.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svscan [ -c maxservices ] [ -t timeout ] [ -d notif ] [ -X consoleholder ] [ dir ]"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svscanctl.c b/src/supervision/s6-svscanctl.c
index b21c611..119d41e 100644
--- a/src/supervision/s6-svscanctl.c
+++ b/src/supervision/s6-svscanctl.c
@@ -2,7 +2,7 @@
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svscanctl [ -zabhitqnN ] svscandir"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index cbda314..979552f 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
@@ -13,7 +13,7 @@
#include <skalibs/sig.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#define USAGE "s6-svstat [ -uwNrpest | -o up,wantedup,normallyup,ready,paused,pid,exitcode,signal,signum,updownsince,readysince,updownfor,readyfor ] [ -n ] servicedir"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -35,7 +35,7 @@ struct funcmap_s
static void pr_up (buffer *b, s6_svstatus_t const *st)
{
- buffer_putsnoflush(b, st->pid && !st->flagfinishing ? st->flagthrottled ? "throttled" : "true" : "false") ;
+ buffer_putsnoflush(b, st->pid && !st->flagfinishing ? "true" : "false") ;
}
static void pr_wantedup (buffer *b, s6_svstatus_t const *st)
@@ -210,8 +210,6 @@ static void legacy (s6_svstatus_t *st, int flagnum)
buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ;
buffer_putnoflush(buffer_1small, " seconds", 8) ;
- if (isup && status.flagthrottled)
- buffer_putnoflush(buffer_1small, ", throttled", 11) ;
if (isup && !normallyup)
buffer_putnoflush(buffer_1small, ", normally down", 15) ;
if (!isup && normallyup)
diff --git a/src/supervision/s6-svunlink.c b/src/supervision/s6-svunlink.c
new file mode 100644
index 0000000..986be65
--- /dev/null
+++ b/src/supervision/s6-svunlink.c
@@ -0,0 +1,49 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/posixplz.h>
+#include <skalibs/types.h>
+#include <skalibs/sgetopt.h>
+#include <skalibs/strerr2.h>
+#include <skalibs/tai.h>
+
+#include <s6/supervise.h>
+
+#define USAGE "s6-svdir-unlink [ -X ] [ -t timeout ] scandir servicename"
+#define dieusage() strerr_dieusage(100, USAGE)
+
+int main (int argc, char const *const *argv)
+{
+ tain tto = TAIN_INFINITE_RELATIVE ;
+ uint32_t options = 1 ;
+ PROG = "s6-svdir-link" ;
+ {
+ unsigned int t = 0 ;
+ subgetopt l = SUBGETOPT_ZERO ;
+ for (;;)
+ {
+ int opt = subgetopt_r(argc, argv, "Xt:", &l) ;
+ if (opt == -1) break ;
+ switch (opt)
+ {
+ case 'X' : options &= ~1U ; break ;
+ case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
+ default : dieusage() ;
+ }
+ }
+ argc -= l.ind ; argv += l.ind ;
+ if (t) tain_from_millisecs(&tto, t) ;
+ }
+ if (argc < 2) dieusage() ;
+
+ if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/')
+ strerr_dief1x(100, "invalid service name") ;
+
+ tain_now_set_stopwatch_g() ;
+ tain_add_g(&tto, &tto) ;
+
+ if (s6_supervise_unlink_names_g(argv[0], argv + 1, 1, options, &tto) == -1)
+ strerr_diefu4sys(111, "prepare unlinking of service ", argv[1], " in scandir ", argv[0]) ;
+ return 0 ;
+}
diff --git a/src/supervision/s6_svlisten_loop.c b/src/supervision/s6_svlisten_loop.c
index 8eee96b..c97427f 100644
--- a/src/supervision/s6_svlisten_loop.c
+++ b/src/supervision/s6_svlisten_loop.c
@@ -8,7 +8,7 @@
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <s6/ftrigr.h>
-#include <s6/s6-supervise.h>
+#include <s6/supervise.h>
#include "s6-svlisten.h"
void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain const *deadline)