Skip to content

Commit f299ad6

Browse files
Merge pull request #101 from sassoftware/develop
merge develop to main for release
2 parents 8eab36e + 2edd822 commit f299ad6

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

playbooks/viya-mmsu/viya-services-stop.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#### Author: SAS Institute Inc. ####
55
####################################################################
66
#
7-
# Copyright (c) 2019-2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
7+
# Copyright (c) 2019-2022, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
88
# SPDX-License-Identifier: Apache-2.0
99
#
1010
---
@@ -262,7 +262,7 @@
262262
when: (stray_processes.stdout != '') and (enable_stray_cleanup|bool != true)
263263

264264
- name: Clean up SAS stray processes if enabled
265-
script: viya-svs.sh cleanps
265+
script: viya-svs.sh cleanps "{{stray_processes.stdout_lines}}"
266266
when: (enable_stray_cleanup|bool == true) and (stray_processes.stdout != '')
267267
check_mode: no
268268
any_errors_fatal: true

playbooks/viya-mmsu/viya-svs.sh

+19-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#### Author: SAS Institute Inc. ####
44
####################################################################
55
#
6-
# Copyright (c) 2019-2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
6+
# Copyright (c) 2019-2022, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
77
# SPDX-License-Identifier: Apache-2.0
88
#
99
#
@@ -91,7 +91,6 @@ do_ps_common()
9191

9292
for p in $LIST
9393
do
94-
#echo "viyasvs: $ACTION $p"
9594
if [[ $p =~ -all-services ]]; then
9695
/etc/init.d/$p $ACTION &
9796
else
@@ -408,7 +407,9 @@ checkspace()
408407

409408
clean_dbps()
410409
{
411-
local LIST=$(ps -e -o "user pid ppid cmd" |grep -E 'sds_consul_health_check|sas-crypto-management'|grep -v grep)
410+
local LIST=$(ps -e -o "user pid ppid cmd"|\
411+
grep -E 'sds_consul_health_check|sas-crypto-management|sds_load_config_service_kv_definition|sas-configuration-cli'|\
412+
grep -v grep |awk 'BEGIN{OFS=" "} { print $1, $2, $4, $5}')
412413
do_cleanps "$LIST"
413414
}
414415

@@ -427,9 +428,11 @@ do_cleanps()
427428
local flag
428429
local NLIST
429430
local LIST=$*
431+
430432
if [[ "$LIST" == "" ]]; then
431-
return
433+
return 0
432434
fi
435+
433436
if [[ "$1" == "-s" ]]; then
434437
flag=$1
435438
shift
@@ -442,13 +445,15 @@ do_cleanps()
442445
NLIST=$(echo "$LIST"|awk '{printf "%s ",$2}')
443446
fi
444447

448+
if [[ "$NLIST" == "" ]]; then
449+
return 0
450+
fi
451+
445452
for p in $NLIST
446453
do
447-
if [[ "$flag" == "" ]]; then
448-
echo "kill -KILL $p"
449-
fi
450454
ps -p $p > /dev/null
451455
if [[ $? == 0 ]]; then
456+
pkill -P $p 2>/dev/null
452457
kill -KILL $p 2>/dev/null
453458
fi
454459
done
@@ -634,12 +639,10 @@ init()
634639
if [[ -f "$SVCFILE" ]]; then
635640
IGNORE=$(sed -e 's/#.*$//' -e '/^$/d' $SVCFILE)
636641
fi
637-
638642
}
639643
######
640644
# main
641645
######
642-
643646
OPT=$1
644647
init
645648

@@ -709,11 +712,14 @@ case "$OPT" in
709712
fi
710713
;;
711714
cleanps)
712-
LIST=$(ps -e -o "user pid ppid cmd"|grep -E '/opt/sas/spre/|/opt/sas/viya/'|grep -v -E 'grep|pgpool|postgres')
715+
shift 1
716+
DLIST=$*
717+
LIST=$(echo "$DLIST" | sed -e "{ s/[][]//g ; s/\,/\n/g ; s/'//g }" | awk '{print $1 " " $2}')
713718
do_cleanps "$LIST"
714719
;;
715720
cleancomp)
716-
LIST=$(ps -e -o "user pid ppid cmd" |grep -E '/opt/sas/spre/|/opt/sas/viya/'|grep compsrv|grep -v grep)
721+
LIST=$(ps -e -o "user pid ppid cmd"|grep -E '/opt/sas/spre/|/opt/sas/viya/'|grep -v grep |\
722+
awk 'BEGIN{OFS=" "} { print $1, $2, $4, $5}'| grep -E 'launcher|compsrv')
717723
do_cleanps "$LIST"
718724
;;
719725
checkspace)
@@ -727,7 +733,8 @@ case "$OPT" in
727733
shift 1
728734
CNT=$*
729735
if [[ $CNT -eq 0 ]]; then
730-
ps -ef|grep -E '/opt/sas/spre/|/opt/sas/viya/|pgpool|postgres'|grep -v grep|awk '{print}'
736+
info=$(ps -ef|grep -E '/opt/sas/spre/|/opt/sas/viya/|pgpool|postgres'|grep -v grep|awk '{print}')
737+
echo "$info"
731738
else
732739
info=$(ps -ef|grep -E '/opt/sas/spre/|/opt/sas/viya/|pgpool|postgres'|grep -v grep)
733740
if [[ "$info" == "" ]]; then

0 commit comments

Comments
 (0)