runit icon indicating copy to clipboard operation
runit copied to clipboard

sv.c: Avoid masking service status with log status

Open Goorzhel opened this issue 2 years ago • 1 comments

Use log status only if service is okay but log isn't. In all other cases, use service status.

Fixes #20.

Before
❯ xbps-query runit | ag 'repo|pkgver'
pkgver: runit-2.1.2_11
repository: https://repo-us.voidlinux.org/current
❯ fd -t f . /etc/sv/issue-20 -X head    
==> /etc/sv/issue-20/run <==
#!/bin/sh
echo 'Sleeping for 60 seconds.'
exec /usr/bin/sleep 60

==> /etc/sv/issue-20/log/run <==
#!/bin/sh
exec /usr/bin/false
❯ ls -l /etc/init.d/issue-20 
lrwxrwxrwx 1 root root 11 Aug  5 18:09 /etc/init.d/issue-20 -> /usr/bin/sv
❯ sudo /etc/init.d/issue-20 status
run: issue-20: (pid 8220) 44s; down: log: 1s, normally up, want up
❯ echo $?  # expecting 0
3
After
❯ xbps-query runit | ag 'repo|pkgver'
pkgver: runit-2.1.2_12
repository: /tmp/xdowngrade-2022-08-05.p555tSVo
❯ sudo /etc/init.d/issue-20 status
run: issue-20: (pid 21075) 30s; down: log: 0s, normally up, want up
❯ echo $?
0

Goorzhel avatar Aug 06 '22 02:08 Goorzhel

@ahesford @ericonr

Goorzhel avatar Aug 06 '22 02:08 Goorzhel