Skip to content

Commit f0c5a60

Browse files
committed
universal way to query service status
1 parent c81a2bf commit f0c5a60

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

bin/v-list-sys-services

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ get_srv_state() {
2323
proc_name=${2-$1}
2424

2525
# Check service status
26-
status=1
27-
if [ ! -z "$(service $srv status| grep running)" ]; then
28-
status=0
29-
fi
26+
status=$(service $srv status 2>/dev/null)
27+
rc=$?
28+
stopped=$(echo $status| grep stop)
3029

31-
if [ $status -eq 0 ]; then
30+
if [ "$rc" -eq 0 ] && [ -z "$stopped" ]; then
3231
state='running'
3332

3433
# Calculate cpu and memory usage

0 commit comments

Comments
 (0)