void-linux / runit

The init system for Void Linux.
https://voidlinux.org
162 stars 22 forks source link

sv.c: Avoid masking service status with log status #21

Closed Goorzhel closed 7 months ago

Goorzhel commented 2 years ago

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 commented 2 years ago

@ahesford @ericonr